Hi, I would want to modify a specific data from Slice of JSON. Is it possible in sjson?
{
"app": "gfgeeks",
"prop": [
{"region": 736,"set": true,"score": 72},
{"region": 563,"set": true,"score": 333}, // modify score to 334; if region == 563 && set == true
{"region": 563,"set": false,"score": 333}
],
"index" : "haskell"
}
I'm currently using gjson to get the json object and I'm able to modify the score to 334. While trying to replace the json back in list, I would want to delete {"region": 563,"set": true,"score": 333} element and add {"region": 563,"set": true,"score": 334}. Currently, sjson is letting me to delete only positional parameter. For example, I could do sjson.Delete(JSON, prop.1) would work. But, the position would often vary. So, I cannot use this approach.
Hi, I would want to modify a specific data from Slice of JSON. Is it possible in
sjson
?I'm currently using gjson to get the json object and I'm able to modify the score to 334. While trying to replace the json back in list, I would want to delete
{"region": 563,"set": true,"score": 333}
element and add{"region": 563,"set": true,"score": 334}
. Currently, sjson is letting me to delete only positional parameter. For example, I could dosjson.Delete(JSON, prop.1)
would work. But, the position would often vary. So, I cannot use this approach.Playground : https://play.golang.org/p/lZu9LezD3Wn
@tidwall