| 23 | ) |
| 24 | |
| 25 | func findFeatureArray(dec *json.Decoder) error { |
| 26 | for { |
| 27 | t, err := dec.Token() |
| 28 | if err == io.EOF { |
| 29 | break |
| 30 | } |
| 31 | if err != nil { |
| 32 | return err |
| 33 | } |
| 34 | if s, ok := t.(string); ok && s == "features" && dec.More() { |
| 35 | // we found the features element |
| 36 | d, err := dec.Token() |
| 37 | if err != nil { |
| 38 | return err |
| 39 | } |
| 40 | if delim, ok := d.(json.Delim); ok { |
| 41 | if delim.String() == "[" { |
| 42 | // we have our start of the array |
| 43 | break |
| 44 | } else { |
| 45 | // A different kind of delimiter |
| 46 | return fmt.Errorf("Expected features to be an array.") |
| 47 | } |
| 48 | } |
| 49 | } |
| 50 | } |
| 51 | |
| 52 | if !dec.More() { |
| 53 | return fmt.Errorf("Cannot find any features.") |
| 54 | } |
| 55 | return nil |
| 56 | } |
| 57 | |
| 58 | func main() { |
| 59 | flag.Parse() |