开发者

JSON - safely add a variable

开发者 https://www.devze.com 2022-12-25 23:37 出处:网络
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

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

精彩评论

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