jsonparser icon indicating copy to clipboard operation
jsonparser copied to clipboard

jsonparser.Delete doesn't handle line breaks comma

Open Houlton opened this issue 5 years ago • 3 comments

Hi,

data := []byte({ "key1": "v1" , "key2": "v2" }`)

newData := jsonparser.Delete(data, "key1") fmt.Println(string(newData))

`

In the output, an extra comma exists, which is not a valid json. { , "key2", "v2" }

Houlton avatar Jul 13 '20 02:07 Houlton

Hi, Please anyone answer this issue?

Houlton avatar Jul 14 '20 02:07 Houlton

@Houlton I didn't reproduce your issue. image

AllenX2018 avatar Dec 10 '20 07:12 AllenX2018

@AllenX2018 that is because you aren't using new lines. https://play.golang.org/p/DD67y0rgT0r

You need to compact the json first: https://play.golang.org/p/YL4fD0KxFHU

It would be great if this lib could support a in-place compacter.

andersfylling avatar Jan 11 '21 23:01 andersfylling