gojsonq-logo

Most often developer needs to consume JSON data from other service and query over them. Querying JSON data is little time consuming. For the last few days I was working on a package for Golang to query JSON data easily. The idea and inspiration comes form PHP-JSONQ by Nahid Bin Azhar. Lets take a sample JSON data to start with:

Now we are ready to query the data, lets see some examples

Example 1

Query: select * from vendor.items where price > 1200 or id null Using gojsonq we can do the query like:

Example 2

Query: select name, price from vendor.items where price > 1200 or id null Using gojsonq we can do the query like:

Example 3

Query: select sum(price) from vendor.items where price > 1200 or id null Using gojsonq we can do the query like:

Note you can use other aggregation function like Min/Max/Avg/Count`

###Example 4 Query: select price from vendor.items where price > 1200 Using gojsonq we can do the query like:

Note: You’ll get a plain array of price

Example 5

Query: select * from vendor.items order by price Using gojsonq we can do the query like:

Example 6

Query: select description from . Using gojsonq we can do the query like:

There are some other useful methods available in the package. The package is still under heavy development! If you have any suggestion or bug report don’t forget to open an issue If you are not using Go, you can also use the same implementation of the package using PHP, Javascript, Python and Kotlin. Links are listed below: php-jsonq js-jsonq py-jsonq kotlin-jsonq

If you like the idea don’t forget to give a STAR :) GithubLink for gojsonq Thank you very much for reading the article