thedevsaddam / gojsonq

A simple Go package to Query over JSON/YAML/XML/CSV Data
https://github.com/thedevsaddam/gojsonq/wiki
MIT License
2.18k stars 140 forks source link

Map[string]interface{} root #8

Closed freman closed 6 years ago

freman commented 6 years ago

Doesn't seem to work when you don't have nicely sliceable structures.

IE: https://www.iinet.net.au/status/event/events.json

I tried Where("DRW", "=", "Darwin") but kept getting nothing back

thedevsaddam commented 6 years ago

@freman Could you please provide the full query?

freman commented 6 years ago

I tried various forms of

gojsonq.New().File("./events.json").From(".").Select("eventid").Where("locations.DRW", "=", "Darwin").Get()

With, and without the from, WhereNotNil, WhereIn. I even tried SortBy("eventid") first

thedevsaddam commented 6 years ago

@freman Hey could you please send a PR to to improve the feature.

We need two things to solve the problem:

  1. Supporting nested query in Where method. e.g: Where("users.posts.title" , "=", "hey")
  2. Traversing the Object properties
thedevsaddam commented 6 years ago

@freman You can convert the object into a list/array and perform the query. From gosjonq v1.2 it supports the DOT(.) notation in Where clause. As we can't support querying the objects at this time, I'm closing the issue.

freman commented 6 years ago

Eh, this defeats the convenience of a library that parses json and makes it searchable. I just switched to streamed decoding.