Documentation
¶
Overview ¶
Package jsont provides a non validating json tokenizer that also emits insignificant tokens (like whitespace).
Example ¶
The following json:
{ "Hello" : "World" }
Will be split into the following tokens:
|{| |"Hello"| |:| |"World"| |}|
Usage ¶
Usage example:
tokenizer := jsont.NewTokenizer(strings.NewReader(jsonInput))
for tokenizer.Next() {
token := tokenizer.Token()
fmt.Println(token.Type)
fmt.Println(token.Value)
}
if tokenizer.Error() != nil {
fmt.Println(tokenizer.Error())
}
Disclaimer ¶
The behavior of this tokenizer is rarely useful. In fact only consider using it, if you are interested in whitespace tokens and don't need to check if the given input is valid json.
Index ¶
Constants ¶
View Source
const ( Empty = iota Whitespace ObjectStart ObjectEnd ArrayStart ArrayEnd Colon Comma FieldName True False Null Integer Float String Unknown )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Tokenizer ¶
type Tokenizer interface {
// Scan advances the Scanner to the next token, which will then be available
// through the Token method. It returns false if no more Tokens are available,
// either because of reaching the end of the input or an error.
Next() bool
// Token returns the most recent token generated by a call to Next.
Token() Token
// Error returns the first non-EOF error that was encountered by the Tokenizer.
Error() error
}
func NewTokenizer ¶
Click to show internal directories.
Click to hide internal directories.