github.com/creachadair/jtree (go): Package jtree implements a JSON scanner and parser.  The Scanner type implements a lexical scanner for JSON.  Construct a scanner from an io.Reader and call its Next method to iterate over the stream. Next advances to the next input token and returns nil, or reports an error:  Next returns io.EOF when the input has been fully consumed. Any other error indicates an I/O or lexical error in the input.  The Stream type implements an event-driven stream parser for JSON.  The parser works by calling methods on a Handler value to report the structure of the input. In case of error, parsing is terminated and an error of concrete type *jtree.SyntaxError is returned.  Construct a Stream from an io.Reader, and call its Parse method. Parse returns nil if the input was fully processed without error. If a Handler method reports an error, parsing stops and that error is returned.  To parse a single value from the front of the input, call ParseOne. This method returns io.EOF if no further values are available:  The Handler interface accepts parser events from a Stream. The methods of a handler correspond to the syntax of JSON values:  Each method is passed an Anchor value that can be used to retrieve location and type information. See the comments on the Handler type for the meaning of each method's anchor value. The Anchor passed to a handler method is only valid for the duration of that method call; the handler must copy any data it needs to retain beyond the lifetime of the call.  The parser ensures that corresponding Begin and End methods are correctly paired, or that a SyntaxError is reported.
Keywords: ast|go|golang|json|parser