jsonparser icon indicating copy to clipboard operation
jsonparser copied to clipboard

use Set to set a string value then the "" is miss

Open orchie opened this issue 7 years ago • 4 comments

i did this configBytes, err := j.Set(configByte, []byte("http://github.com"), "test") then the json is "test":http://github.com, i try a int like configBytes, err := j.Set(configByte, []byte("2"), "test") then it works "test":2, because it's' ok finally i try this configBytes, err := j.Set(configByte, []byte("\"http://github.com\""), "test") then it works~ but i feel it's not cool and not frendly to noob,right?

orchie avatar Dec 25 '18 16:12 orchie

Any news on that?

v-braun avatar Jul 21 '19 20:07 v-braun

+1

andrewspringman avatar Jul 23 '19 17:07 andrewspringman

+1

fastcity avatar Jul 31 '19 05:07 fastcity

Set will exactly set what your []byte contains. If you don't like to handle the escape with the slash, you may try a backtick string

configBytes, err := j.Set(configByte, []byte(`"http://github.com"`), "test")

output: "test":"http://github.com"

AllenX2018 avatar Mar 19 '20 02:03 AllenX2018