You should consider a JSON parser and use it to convert that JSON document to a runtime object, JSON.NET would work in this case.
Json.NET - Newtonsoft[
^]. These parsers would convert your documents properly, without having to worry about invalid data (and if the document is invalid, it would throw exception). Have a look at the JSON schema validator,
JSON Schema Validator - Newtonsoft[
^], and then try to parse that value in any online JavaScript based JSON parser (
JSON.parse()
) and you can see for yourself. Are you using your own build parser? The following is a JavaScript sample for this,
Edit fiddle - JSFiddle[
^]
(function() {
alert(
JSON.parse("{\"@odata.context\":\"http://192.168.0.126:49540/odata/$metadata#Edm.String\",\"value\":\"The Chinese Stai\"}")
.value);
})();
Now as for C#, the code to do that would be,
dynamic obj = JsonConvert.DeserializeObject(data);
Console.WriteLine(obj.value);
If everything goes right, you will see that output. I wrote an article on the topic of JSON and C#, you should consider reading that,
From zero to hero in JSON with C#[
^]. It also explains the process of extracting dynamically built JSON documents in dynamic objects in C#, see the comments to that article.