4 Comments
User's avatar
amnonbc's avatar

Any reason you suggest jsoniter, but not encoding/json/v2?

Have you tried porting to the new v2 api with its zero alloc encoding?

Were the savings this produced inadequate?

Expand full comment
Julien Singler's avatar

Hi, good catch.

I honestly didn’t try the encoding/json/v2 mainly because it’s still experimental. I know the greenteagc is experimental as well but it’s more of a devops concern and consequences would be quite different.

If the encoding/json/v2 has an edge case or a bug it could result in unexpected payload, and in production it could corrupt data. In complex systems and/or in high volumes that can be catastrophic.

jsoniter too, but the edge cases are known now.

However, I’m quite excited about encoding/json/v2 and happy to use it once it’s battle tested and deemed stable.

Expand full comment
amnonbc's avatar

The testing of v2 has been thoughough, so I would be very surprised if you came across an edge case where it encodes or decodes incorrectly.

v2 is experimental in the sense that it is not yet covered by the Go compatibility guarantee - its authors reserve the right to make breaking changes to the API,

in response to user feedback and use experience out in the wild.

Expand full comment
Julien Singler's avatar

That's good to know, I will test encoding/json/v2 beginning of January then, I will check to do a benchmark to see if it makes a big difference (allocs / speed) with jsoniter in a real world app.

Expand full comment