4 ms·
> particularly high-performance small services that do things like fling JSON around :/ Their json system reflects and allocates like a mad-man. It's probably
by codemac 11y ago
> particularly high-performance small services that do things like fling JSON around
:/ Their json system reflects and allocates like a mad-man. It's probably one of the slowest parts of the std library.
- lobster_johnson 11y agoDo you know of a faster JSON library? I've been struggling with this. My particular use case is that I don't want any fancy struct unmarshaling; I just want the equivalent of map[string]interface{}.
- nicksardo 11y agohttps://github.com/nicksardo/jsonpath https://github.com/nicksardo/jsonpath can pull out parts of a JSON document without unmarshalling.
- lobster_johnson 11y agoThat's really neat, thanks (do you have any benchmarks comparing it to Go's JSON?), but doesn't cover my use case. I want all the values in a map-like API. I don't know anything about the shape of the contents, names of the keys, etc.
- ptman 11y agoWhich libraries have you looked at? https://github.com/pquerna/ffjson https://github.com/pquerna/ffjson and https://github.com/benbjohnson/megajson https://github.com/benbjohnson/megajson claim to be faster
- lobster_johnson 11y agoLooked at both. ffjson is a library that generates the marshaling/unmarshaling Go code for your structs, so it doesn't support my use case at all. megajson is abandonware ("This tool is unmaintained. Please use ffjson instead"). go-codec [1] is very good, and can do things like interning string keys to reduce allocation overhead, but it's not faster than encoding/json when working on plain maps. [1] https://github.com/ugorji/go https://github.com/ugorji/go
- matthewmacleod 11y agoYes, this is a good point (and I've hit this in the builtin XML unmarshalling too). I should point out I'm mostly looking at go in comparison with Ruby rather than the C, so the JSON implementation is still high-performance by that metric :)