![]() Let's say you want to find the sum of the 'price' of the 'products'. property - the property name of the data.This method will behave like where(key, 'contains', val) method call. This method will behave like where(key, 'endswith', value) method call. This method will behave like where(key, 'startswith', value) method call. This method will behave like where(key, '!=', 'None') method call. This method will behave like where(key, '=', 'None') method call. This method will behave like where(key, 'notin', value) method call. This method will behave like where(key, 'in', value) method call. Let's say you want to find the 'users' who has id of 1. This would only works for String type data.Ĭase_insensitive - if True, the search will be case insensitive, False is default. endswith : Check if the value of given key in data ends with (has a suffix of) the given value.This would only works for String type data. startswith : Check if the value of given key in data starts with (has a prefix of) the given value.notin : Check if the value of given key in data is not exists in given val.in : Check if the value of given key in data is exists in given value.notnull : Check if the value of given key in data is not null ( value parameter in where() can be omitted for this operator).null : Check if the value of given key in data is null ( value parameter in where() can be omitted for this operator).= : Check if value of given key in data is Greater than or Equal of value.> : Check if value of given key in data is Greater than value.The following operands are available to use: Operator - operand to be used for matching. You can download a single binary, scp it to a far away machine of the same type, and expect it to work. jq is written in portable C, and it has zero runtime dependencies. It can be a int, string, bool or even float - depending on the operator. jq is like sed for JSON data - you can use it to slice and filter and map and transform structured data with the same ease that sed, awk, grep and friends let you play with text. Or you can pass a Function here to group multiple query inside it. where(key, operator, value, case_insensitive) Let's say you have a file named data.json. Details can be found in other API examples. This method is the alternative of set json file path. You need to call it finally after using some query methods. This method will execute queries and will return the resulted data. Also detailed examples of each API can be found here. To get a better idea of the examples see that JSON data first. ![]() Let's explore the full API to see what else magic this library can do for you.įollowing API examples are shown based on the sample JSON data given here. ![]() Here is a quick example: avg_temp : float = jq. Once you created your query object you can then query over it usingĪ variety of methods. String ( """ """ ) # OR jq : JsonQuery = JsonQuery (). TOMLFile / toml_file, TOMLString / toml_string or Using either File / file, String / string, ![]() Next create a new JsonQuery instance and load the data into the query Operators for the Where method: holds, notHolds Installation pip install pyjsonqueryįirst import the JsonQuery class into your project from pyjsonq import JsonQuery Useful stuff to it, but for now the only thing I added are two Over time I will potentially update this package and add more fun and Simple API and is just a beauty to work with. I decided to rewrite this package in Python because I love it's It is a rewrite of the Go package "GoJSONQ" which you can find here: PyJsonQ is an easy to use and package to query json data. ![]()
0 Comments
Leave a Reply. |