Documentation ¶
Index ¶
Constants ¶
const ( String // the data is a JSON String Number // the data is a JSON Number True // the data is a JSON True False // the data is a JSON False Null // the data is a JSON NUll Object // the data is a JSON Object (open or close character) Array // the data is a JSON Array (open or close character) Comma // the data is a JSON comma character ',' Colon // the data is a JSON colon character ':' Start // the data is the start of the JSON document End // the data is the end of the JSON document Open // the data is an open character (Object or Array, '{' or '[') Close // the data is an close character (Object or Array, '}' or ']') Key // the data is a JSON Object key Value // the data is a JSON Object or Array value Escaped // the data is a String with at least one escape character ('\') Sign // the data is a signed Number (has a '-' prefix) Dot // the data is a Number has a dot (radix point) E // the data 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
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.