title: How to escape embedded JSON after unescape
body: <p>When serializing with Json.NET, I need to escape embedded JSON after previously unescaping while deserializing. Which means I unescaped following JSON according to <a href="https://stackoverflow.com/questions/39154043/how-do-i-convert-an-escaped-json-string-within-a-json-object/39154630#39154630">this</a> post. </p>
  
  <p>Here is my JSON:</p>
  
  <pre><code>{  
     "Message":null,
     "Error":false,
     "VData":{  
        "RNumber":null,
        "BRNumber":"Session1"
     },
     "onlineFields":{  
        "CCode":"Web",
        "MNumber":"15478655",
        "Product":"100",
        "JsonFile":"      {  
           \"evaluation\":{  
              \"number\":[  
                 {  
                    \"@paraID\":\"1000\",
                    \"@Value\":\"\",
                    \"@label\":\"We are america\"
                 },
                 {  
                    \"@paraID\":\"2000\",
                    \"@Value\":\"100\",
                    \"@label\":\"We are japan\"
                 },
                 {  
                    \"@paraID\":\"3000\",
                    \"@Value\":\"1000\",
                    \"@label\":\"We are UK\"
                 },
                 {  
                    \"@paraID\":\"4000\",
                    \"@Value\":\"\",
                    \"@label\":\"We are China\"
                 }
              ]
           }
        } "     
     }
  }
  </code></pre>
  
  <p>After unescaping, I bind the above JSON to my model classes. And it works properly. to Bind JSON to a model I used following code.</p>
  
  <pre><code>private static void showJSON(string testJson){
  
      Response response = JsonConvert.DeserializeObject&lt;Response&gt;(testJson);
  
      var dropdowns = response.OnlineFields.JsonFile;
  
      string json = JsonConvert.SerializeObject(dropdowns, Newtonsoft.Json.Formatting.Indented);
  
      Console.WriteLine(json);
  }
  </code></pre>
  
  <p>After bind JSON to model, there has some logic to set values to JSON and returns unescaped JSON. which means it also returns unescaped <code>JsonFile</code>, I again need above JSON format (escaped embedded <code>JsonFile</code>) to send to the client API. </p>
  
  <p>This is unescaped JSON format, I need convert this to above escaped JSON (escaped embedded <code>JsonFile</code>)</p>
  
  <pre><code>{  
     "Message":null,
     "Error":false,
     "VData":{  
        "RNumber":null,
        "BRNumber":"Session1"
     },
     "onlineFields":{  
        "CCode":"Web",
        "MNumber":"15478655",
        "Product":"100",
        "JsonFile":{  
           "evaluation":{  
              "number":[  
                 {  
                    "@paraID":"1000",
                    "@Value":"",
                    "@label":"We are america"
                 },
                 {  
                    "@paraID":"2000",
                    "@Value":"100",
                    "@label":"We are japan"
                 },
                 {  
                    "@paraID":"3000",
                    "@Value":"1000",
                    "@label":"We are UK"
                 },
                 {  
                    "@paraID":"4000",
                    "@Value":"",
                    "@label":"We are China"
                 }
              ]
           }
        }
     }
  }
  </code></pre>
  
  <p>Previously I asked a <a href="https://stackoverflow.com/questions/51802068/how-to-escape-especial-characters-in-json">question</a> for how to directly deserialize such embedded JSON into c# classes, but the answer there did not explain how to re-serialize in the same format.  I need to extend the answer from that previous question to writing.</p>