Standard library / encoding/json
encoding/json.Decoder.More()
Report whether another element is available in the current array or object. Use Token to consume opening and closing delimiters. Expected stdout: '1\n2\n'.
Formal Syntax & Structure
go syntaxgo
func (dec *Decoder) More() boolReturn Value
bool
Whether the stated condition holds.
Working Example
Example Snippetgo
package main
import ( "encoding/json" "fmt" "strings")
func must(e error) { if e != nil { panic(e) }}
func main() { d := json.NewDecoder(strings.NewReader("[1,2]")) _, e := d.Token() must(e) for d.More() { var n int must(d.Decode(&n)) fmt.Println(n) } _, e = d.Token() must(e)}