{"library":"pyjq","title":"pyjq - Python Binding for jq","description":"pyjq is a Python binding for the `jq` command-line JSON processor. It allows executing `jq` queries against Python dictionaries and lists, providing flexible and powerful JSON data manipulation capabilities. As of version 2.6.0, it primarily offers a `jq()` function with options for single or multiple results, as well as a `run()` function for CLI-like behavior. It is actively maintained with regular updates.","language":"python","status":"active","last_verified":"Fri Apr 17","install":{"commands":["pip install pyjq"],"cli":null},"imports":["import pyjq"],"auth":{"required":false,"env_vars":[]},"quickstart":{"code":"import pyjq\nimport json\n\ndata = {\n    \"items\": [\n        {\"name\": \"Apple\", \"price\": 1.0, \"category\": \"Fruit\"},\n        {\"name\": \"Banana\", \"price\": 0.5, \"category\": \"Fruit\"},\n        {\"name\": \"Carrot\", \"price\": 0.3, \"category\": \"Vegetable\"}\n    ]\n}\n\n# Select names of all fruits, returning a list of results\nfruit_names = pyjq.jq('.items[] | select(.category == \"Fruit\") | .name', data, all_results=True)\nprint(f\"Fruit names: {list(fruit_names)}\")\n\n# Get the price of the first item (returns an iterator by default)\n# Use next() to get the first value from the iterator\nfirst_item_price_iterator = pyjq.jq('.items[0].price', data)\nprint(f\"First item price (iterator): {next(first_item_price_iterator)}\")\n\n# Using pyjq.run for CLI-like behavior, processing a JSON string\njson_string = json.dumps(data)\nall_prices_iterator = pyjq.run('.items[].price', text_input=json_string)\nprint(f\"All prices (from string input): {list(all_prices_iterator)}\")","lang":"python","description":"This quickstart demonstrates how to use `pyjq.jq()` to query Python dictionaries, including how to handle multiple results with `all_results=True`. It also shows `pyjq.run()` for processing raw JSON string inputs, mimicking the `jq` CLI.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":null}