ay89 ay89 - 11 months ago 48
JSON Question

how to update a particular value in json?

I am using newtonsoft json library. I want to update value of a token "Status" from false to true in following json. How can I do that?:

"type": "FeatureCollection",
"Status": false,
"crs": {
"type": "EPSG",
"properties": {
"code": 28992


You can deserialize it, modify the value and serialize it again

dynamic jsonObject = Newtonsoft.Json.JsonConvert.DeserializeObject(jsonString);
jsonObject.Status = true;
var modifiedJsonString = Newtonsoft.Json.JsonConvert.SerializeObject(jsonObject);