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.
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:
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 :
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.