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

Find map's element using Where query #24

Open thedevsaddam opened 6 years ago

thedevsaddam commented 6 years ago

Query: SELECT * FROM . WHERE age < 30

{
  "one":{
    "name":"John",
    "age":28
  },
  "two":{
    "name":"Jane",
    "age":30
  },
  "three":{
    "name":"Tom",
    "age":28
  }
}

Result:


{
  "one":{
    "name":"John",
    "age":28
  },
  "three":{
    "name":"Tom",
    "age":28
  }
}
mrgleeco commented 5 years ago

I am also wondering if this is supported at this time

With input like {"a": {"x": 1, "b2"}}

I tried with .From("a").Where("x", '=", 1).Get() with no results.

..or if i have missed or misunderstood docs. Looking closer looks like Where wants array context somewhere

thedevsaddam commented 5 years ago

Yes, you are right.Where will work on array context

mrgleeco commented 5 years ago

..but also, to be clear:Where will NOT work in single object context (as illustrated above)?

Where can i help here? :P

thedevsaddam commented 5 years ago

..but also, to be clear:Where will NOT work in single object context (as illustrated above)?

Where can i help here? :P

If you want to send PR to solve the problem you are welcome

mrgleeco commented 5 years ago

opened https://github.com/thedevsaddam/gojsonq/pull/57