Documentation ¶
Index ¶
Constants ¶
const ( String // token is a JSON String Number // token is a JSON Number True // token is a JSON True False // token is a JSON False Null // token is a JSON NUll Object // token is a JSON Object (open or close character) Array // token is a JSON Array (open or close character) Comma // token is a JSON comma character ',' Colon // token is a JSON colon character ':' Start // token is the start of the JSON document End // token is the end of the JSON document Open // token is an open character (Object or Array, '{' or '[') Close // token is a close character (Object or Array, '}' or ']') Key // token is a JSON Object key Value // token is a JSON Object or Array value Escaped // token is a String with at least one escape character ('\') Sign // token is a signed Number (has a '-' prefix) Dot // token is a Number that has a dot (radix point) E // token is a Number in scientific notation (has 'E' or 'e') )
Bit flags passed to the "info" parameter of the iter function which provides additional information about the current JSON Element.
Variables ¶
This section is empty.
Functions ¶
func Parse ¶
Parse JSON. The iter function is a callback that fires for every element in the JSON document. Elements include all values and tokens. The 'start' and 'end' params are the start and end indexes of their respective element, such that json[start:end] will equal the complete element data. The 'info' param provides extra information about the element data. Returning 0 from 'iter' will stop the parsing. Returning 1 from 'iter' will continue the parsing. Returning -1 from 'iter' will skip all children elements in the current Object or Array, which only applies when the 'info' for current element has the Open bit set, otherwise it effectively works like returning 1. This operation returns zero or a negative value if an error occured. This value represents the position that the parser was at when it discovered the error. To get the true offset multiple this value by -1.
e := Parse(json, iter) if e < 0 { pos := e * -1 return fmt.Errorf("parsing error at position %d", pos) }
This operation returns a positive value when successful. If the 'iter' stopped early then this value will be the position the parser was at when it stopped, otherwise the value will be equal the length of the original json document.
Types ¶
This section is empty.