buger/jsonparser

jsonparser.Delete doesn't handle line breaks comma

Houlton opened this issue ยท 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"
}

Hi,
Please anyone answer this issue?

@Houlton I didn't reproduce your issue.
image

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