8000 Is a top-level array not supported ? · Issue #12 · jmoiron/jsonq · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
Is a top-level array not supported ? #12
Open
@Gys

Description

@Gys

Hi

I am trying to parse an array but cannot get is to work.
My test code below produces an error: Array index on non-array map[]
Is a first top-level array not supported ?

var jdata =[ { "elem1": { "id": 1 } }, { "elem2": { "id": 1 } } ]

func main() {
data := map[string]interface{}{}
dec := json.NewDecoder(strings.NewReader(jdata))
dec.Decode(&data)
jq := jsonq.NewQuery(data)
v, err := jq.Int("0", "elem1", "id")
if err != nil {
fmt.Printf("ERROR: %s\n", err)
return
}
fmt.Printf("%v\n", v)
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0