Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to update a particular value in json?

Tags:

json

c#

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
        }
    }
}
like image 648
Ankit Avatar asked Sep 16 '25 22:09

Ankit


1 Answers

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);
like image 62
Esteban Elverdin Avatar answered Sep 19 '25 10:09

Esteban Elverdin