How to keep HTML line in JSON



  • How to keep the HTML arbitrary line in Json's file. For example

    {
        "id": 1,
        "html": " style type = \"text/css\" "
    }
    

    There's a screen problem. How do we avoid them?



  • how to keep the HTML arbitrary line in Json file

    #r "E:\Program Files\Microsoft SDKs\Windows Azure\.NET SDK\v2.3\ref\Newtonsoft.Json.dll"
    

    using Newtonsoft.Json;
    using Newtonsoft.Json.Linq;

    var o = JObject.Parse("{'id':1}");
    o["html"] = JToken.FromObject("<div>"hello"</div>");
    System.IO.File.WriteAllText(@"c:\temp\json.txt", o.ToString());

    Turns into the file:

    {
    "id": 1,
    "html": "<div>"hello"</div>"
    }



Suggested Topics

  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2