How do I safely add a variable to JSON data with C#? For instance I might have [{"data": "data"}, {"data": "data"}]
or I might have {"data": "data"}
. How do I add a new variable "newdata": "newdata"
to the structure?
views:
27answers:
1
+1
A:
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,
Marvin Smit
2010-04-09 07:25:15
Won't be able to test it until Monday, but I think you are on the right track here.
HeavyWave
2010-04-09 08:54:43