github.com/soluble-ai/go-jnode (go): The jnode package handles generic JSON documents building on the support provided by Go's "encoding/json".  The API is loosely based on the Java's https://github.com/FasterXML/jackson-databind.  The Node type represents a generic JSON node (e.g. text, bool, null, int, float, array, or object.)  Here's some ways to create a Node:  The Put methods accept simple types, slices, maps and other Node's.  For complex types the argument will be copied, and it may be modified (see implementation note below.)  For Object Node's, use Path:  All elements of an Object can be accessed via Entries(). All elements of an Array Node can be accessed via Elements(). Both methods return empty maps or slices if the Node is not an Object or Array respectively.  A Node's String() method returns JSON:  Note that because jnode is building on the generic JSON support in Go, the order of fields in an Object is unpredictable.  A Node holds an interface{}, which stores the unwrapped Go value. (A Node does not contain another Node, only the basic generic JSON values.) For Array values ([]interface{}) the Node holds a pointer to the slice instead of the slice directly.  (This is necessary because Append creates new slices.)  For this reason, when jnode accepts an []interface{} or map[string]interface{} (via Put, Append, FromSlice, or FromMap) it will rewrite any slices to pointers to slices.  During JSON marshalling the code walks through the value replacing pointers to slices with slices, then undoing the replacement afterwards. Likewise, during unmarshalling the code walks through the value replacing slices with pointers to the slices.
Keywords: golang|json