开发者

JSON - safely add a variable

How do I safely add a variable to JSON data with C#? For instance I might have 开发者_如何学Python[{"data": "data"}, {"data": "data"}] or I might have {"data": "data"}. How do I add a new variable "newdata": "newdata" to the structure?


If you have the availability of the .Net 3.5SP1 framework, have a look at the JSONReaderWriterFactory class. It makes a XmlDictionaryReader/Writer for use with JSON.

You can use a reader/writer combination to read what's there, write what was there and add your own entries.

Hope this helps,

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜