I need to read a JSON configuration file, modify a value and then save the modified JSON back to the file again. The JSON is as simple as it gets:
{
"
The problem is that you are using config.ToString()
, so the object is already serialised into a string and formatted when you write it using the JsonTextWriter
.
Use a serialiser to serialise the object to the writer instead:
JsonSerializer serializer = new JsonSerializer();
serializer.Serialize(jw, config);