tidwall / sjson

Set JSON values very quickly in Go
MIT License
2.4k stars 165 forks source link

Set array of values to the JSON #73

Open lkumarjain opened 1 year ago

lkumarjain commented 1 year ago

In order to be able to set an array of values and do that efficiently we added SetBytesOptionsManyByGetResult() so that all of the values are set at once instead of having to go through the JSON for each value separately. It inserts each value at a specified index maintaining the diff between the original and inserted value, so that the next time the insert happens, the index of the original value will be moved in accordance with the diff.

The other improvement, if you already searched the JSON and have the result of gjson.Get(), then you can just pass it to sjson.Set() instead of having to fire another search inside.

57