I use System.Web.HttpUtility.JavaScriptStringEncode
string quoted = HttpUtility.JavaScriptStringEncode(input);
More Related Contents:
- Deserialize JSON into C# dynamic object?
- How to implement custom JsonConverter in JSON.NET?
- Does Json.NET cache types’ serialization information?
- JavaScriptSerializer – JSON serialization of enum as string
- Using JsonConvert.DeserializeObject to deserialize Json to a C# POCO class
- How to write a JSON file in C#?
- Parse Json string in C#
- Escape Special Character in Regex
- How do I deserialize a complex JSON object in C# .NET?
- Convert json to a C# array?
- Not ableTo Serialize Dictionary with Complex key using Json.net
- JSON library for C# [closed]
- How to handle json that returns both a string and a string array? [duplicate]
- Proper JSON serialization in MVC 4
- Complex type is getting null in a ApiController parameter
- ASP.NET Core 3.0 System.Text.Json Camel Case Serialization
- Read and Write file on streamingAssetsPath
- Iterating over JSON object in C#
- Deserialize JSON to anonymous object
- Find and return JSON differences using newtonsoft in C#?
- How to convert XML to JSON using C#/LINQ?
- Ignoring null fields in Json.net
- Convert DataTable to JSON with key per row
- Json.net serialize numeric properties as string
- Json.Net PopulateObject – update list elements based on ID
- Deserialize JSON to Array or List with HTTPClient .ReadAsAsync using .NET 4.0 Task pattern
- Null-coalescing operator returning null for properties of dynamic objects
- How to globally set default options for System.Text.Json.JsonSerializer?
- Is there a way in Json.NET serialization to distinguish between “null because not present” and “null because null”?
- DataContractJsonSerializer – Deserializing DateTime within List