Recommend intermediate-level library for reading and writing JSON

Is there an intermediate level library for Go that can be used to read and write JSON? I need to be able to walk the JSON data structure when reading and need to construct the JSON structure piece by piece. I came across which can read JSON but I also need to write JSON but didn’t find much else.

An example of such a library form the Java world is, is there an equivalent for the Go community?

I looked at encoding/json, there is the very high-level marshal and unmarshal support (which is nice) and I also noticed some low-level support for reading tokens but there didn’t appear to be an intermediate level, unless I am mistaken? For example, I’d like to read an entire array of elements, to check is an element exists etc. In java or other languages you right type something like this to read in an array from JSON:

JSONArray arr = obj.getJSONArray(“posts”);

I was wondering id there was anything similar in Go?

Hey @hsauro hope you are doing great, if I understand you right. You may want to use an embedded object, and than you can unmarshal your json normally.

type Book struct {
Name string
Categories []Category

type Category struct {
Description string

I hope this helps.

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.