Calling Set on nested JSON object returns invalid JSON after setting value
If I call set on a deep nested JSON, the value after it returns misses the quotes required for a valid JSON
Input JSON:
{
"ipv4":{
"name":"testDependency",
"source":{
"address":{
"group":"testDepenffdency",
"ff":"aa"
},
"port":{
"any":true
}
},
"uuid":"653e5654-b56b-47c1-b4e5-206acbb28f7a"
}
}
code invoked:
keysList := []string{"ipv4", "source", "address", "group"}
setVal := []byte(`KaranTest`)
outputVal, err := jsonparser.Set([]byte(buggedString), setVal, keysList...)
Output:
{
"ipv4":{
"name":"testDependency",
"source":{
"address":{
"group":KaranTest,
"ff":"aa"
},
"port":{
"any":true
}
},
"uuid":"653e5654-b56b-47c1-b4e5-206acbb28f7a"
}
}
Here's an example of the problem: https://play.golang.org/p/YT3Ttz0Irib
However, if I pass :
setVal := []byte(`"KaranTest"`)
It works as expected. Most of the time in programs we don't get strings like that. Is this by design? 😊 I'll have to wrap strings around " " to get around this issue.
yes,I found it, too
I got this issue today
I found this too, any update?
I get this issue too. How to deal with it?
I found a way to deal with it
