diff options
author | S. Solomon Darnell | 2025-03-28 21:52:21 -0500 |
---|---|---|
committer | S. Solomon Darnell | 2025-03-28 21:52:21 -0500 |
commit | 4a52a71956a8d46fcb7294ac71734504bb09bcc2 (patch) | |
tree | ee3dc5af3b6313e921cd920906356f5d4febc4ed /.venv/lib/python3.12/site-packages/jsonpath_python-1.0.6.dist-info | |
parent | cc961e04ba734dd72309fb548a2f97d67d578813 (diff) | |
download | gn-ai-master.tar.gz |
Diffstat (limited to '.venv/lib/python3.12/site-packages/jsonpath_python-1.0.6.dist-info')
6 files changed, 308 insertions, 0 deletions
diff --git a/.venv/lib/python3.12/site-packages/jsonpath_python-1.0.6.dist-info/INSTALLER b/.venv/lib/python3.12/site-packages/jsonpath_python-1.0.6.dist-info/INSTALLER new file mode 100644 index 00000000..a1b589e3 --- /dev/null +++ b/.venv/lib/python3.12/site-packages/jsonpath_python-1.0.6.dist-info/INSTALLER @@ -0,0 +1 @@ +pip diff --git a/.venv/lib/python3.12/site-packages/jsonpath_python-1.0.6.dist-info/LICENSE b/.venv/lib/python3.12/site-packages/jsonpath_python-1.0.6.dist-info/LICENSE new file mode 100644 index 00000000..73dd787c --- /dev/null +++ b/.venv/lib/python3.12/site-packages/jsonpath_python-1.0.6.dist-info/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2020 zhangxianbing + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/.venv/lib/python3.12/site-packages/jsonpath_python-1.0.6.dist-info/METADATA b/.venv/lib/python3.12/site-packages/jsonpath_python-1.0.6.dist-info/METADATA new file mode 100644 index 00000000..5dc83942 --- /dev/null +++ b/.venv/lib/python3.12/site-packages/jsonpath_python-1.0.6.dist-info/METADATA @@ -0,0 +1,272 @@ +Metadata-Version: 2.1 +Name: jsonpath-python +Version: 1.0.6 +Summary: A more powerful JSONPath implementation in modern python +Home-page: https://github.com/zhangxianbing/jsonpath-python +Author: zhangxianbing +License: UNKNOWN +Platform: UNKNOWN +Classifier: Development Status :: 3 - Alpha +Classifier: Intended Audience :: Developers +Classifier: License :: OSI Approved :: MIT License +Classifier: Programming Language :: Python :: 3.6 +Requires-Python: >=3.6 +Description-Content-Type: text/markdown +License-File: LICENSE + +- [jsonpath-python](#jsonpath-python) + - [Features](#features) + - [JSONPath Syntax](#jsonpath-syntax) + - [Operators](#operators) + - [Examples](#examples) + - [Select Fields](#select-fields) + - [Recursive Descent](#recursive-descent) + - [Slice](#slice) + - [Filter Expression](#filter-expression) + - [Sorter Expression](#sorter-expression) + - [Field-Extractor Expression](#field-extractor-expression) + - [Appendix: Example JSON data:](#appendix-example-json-data) + - [Todo List](#todo-list) + +# jsonpath-python + +A more powerful JSONPath implementation in modern python. + +## Features + +- [x] **Light. (No need to install third-party dependencies.)** +- [x] **Support filter operator, including multi-selection, inverse-selection filtering.** +- [x] **Support sorter operator, including sorting by multiple fields, ascending and descending order.** +- [x] Support basic semantics of JSONPath. +- [x] Support output modes: VALUE, PATH. +- [ ] Support embedded syntax. +- [ ] Support user-defined function. +- [ ] Support parent operator. + +## Installation + +```bash +pip install jsonpath-python + +# import +>>> from jsonpath import JSONPath +``` + +## JSONPath Syntax + +The JSONPath syntax in this project borrows from [JSONPath - XPath for JSON](http://goessner.net/articles/JSONPath/) and is **modified** and **extended** on it. + +### Operators + +| Operator | Description | +| ---------------- | ---------------------------------------------------------------------------- | +| `$` | the root object/element | +| `@` | the current object/element | +| `.` or `[]` | child operator | +| `..` | recursive descent | +| `*` | wildcard | +| `''` | (Experimental) wrap field with special character: dots(`.`) and space (` `). | +| `start:end:step` | array slice operator (It's same as the slice in python) | +| `?()` | applies a filter expression | +| `/()` | applies a sorter expression | +| `()` | applies a field-extractor expression | + +### Examples + +Before running the following example, please import this module and the example data: + +```python +>>> from jsonpath import JSONPath + +# For the data used in the following example, please refer to the Appendix part. +``` + +#### Select Fields + +Select a field: + +```python +>>> JSONPath("$.book").parse(data) +[[{'category': 'reference', 'author': 'Nigel Rees', 'title': 'Sayings of the Century', 'price': 8.95, 'brand': {'version': 'v1.0.0'}}, {'category': 'fiction', 'author': 'Evelyn Waugh', 'title': 'Sword of Honour', 'price': 12.99, 'brand': {'version': 'v0.0.1'}}, {'category': 'fiction', 'author': 'Herman Melville', 'title': 'Moby Dick', 'isbn': '0-553-21311-3', 'price': 8.99, 'brand': {'version': 'v1.0.2'}}, {'category': 'fiction', 'author': 'J. R. R. Tolkien', 'title': 'The Lord of the Rings', 'isbn': '0-395-19395-8', 'price': 22.99, 'brand': {'version': 'v1.0.3'}}]] +>>> JSONPath("$[book]").parse(data) +[[{'category': 'reference', 'author': 'Nigel Rees', 'title': 'Sayings of the Century', 'price': 8.95, 'brand': {'version': 'v1.0.0'}}, {'category': 'fiction', 'author': 'Evelyn Waugh', 'title': 'Sword of Honour', 'price': 12.99, 'brand': {'version': 'v0.0.1'}}, {'category': 'fiction', 'author': 'Herman Melville', 'title': 'Moby Dick', 'isbn': '0-553-21311-3', 'price': 8.99, 'brand': {'version': 'v1.0.2'}}, {'category': 'fiction', 'author': 'J. R. R. Tolkien', 'title': 'The Lord of the Rings', 'isbn': '0-395-19395-8', 'price': 22.99, 'brand': {'version': 'v1.0.3'}}]] +``` + +(**Experimental**) Select a field with special character: dots(`.`) and space (` `). + +```python +>>> JSONPath("$.'a.b c'").parse(data) +['a.b c'] +>>> JSONPath("$['a.b c']").parse(data) +['a.b c'] +``` + +Select multiple fields: + +```python +>>> JSONPath("$[bicycle,scores]").parse(data) +[{'color': 'red', 'price': 19.95}, {'math': {'score': 100, 'avg': 60}, 'english': {'score': 95, 'avg': 80}, 'physic': {'score': 90, 'avg': 70}, 'chemistry': {'score': 85, 'avg': 80}, 'chinese': {'score': 60, 'avg': 75}}] +``` + +Select all fields using wildcard `*`: + +```python +>>> JSONPath("$.*").parse(data) +['a.b c', [{'category': 'reference', 'author': 'Nigel Rees', 'title': 'Sayings of the Century', 'price': 8.95, 'brand': {'version': 'v1.0.0'}}, {'category': 'fiction', 'author': 'Evelyn Waugh', 'title': 'Sword of Honour', 'price': 12.99, 'brand': {'version': 'v0.0.1'}}, {'category': 'fiction', 'author': 'Herman Melville', 'title': 'Moby Dick', 'isbn': '0-553-21311-3', 'price': 8.99, 'brand': {'version': 'v1.0.2'}}, {'category': 'fiction', 'author': 'J. R. R. Tolkien', 'title': 'The Lord of the Rings', 'isbn': '0-395-19395-8', 'price': 22.99, 'brand': {'version': 'v1.0.3'}}], {'color': 'red', 'price': 19.95}, {'math': {'score': 100, 'avg': 60}, 'english': {'score': 95, 'avg': 80}, 'physic': {'score': 90, 'avg': 70}, 'chemistry': {'score': 85, 'avg': 80}, 'chinese': {'score': 60, 'avg': 75}}] +``` + +#### Recursive Descent + +```python +>>> JSONPath("$..price").parse(data) +[8.95, 12.99, 8.99, 22.99, 19.95] +``` + +#### Slice + +Support python-like slice. + +```python +>>> JSONPath("$.book[1:3]").parse(data) +[{'category': 'fiction', 'author': 'Evelyn Waugh', 'title': 'Sword of Honour', 'price': 12.99, 'brand': {'version': 'v0.0.1'}}, {'category': 'fiction', 'author': 'Herman Melville', 'title': 'Moby Dick', 'isbn': '0-553-21311-3', 'price': 8.99, 'brand': {'version': 'v1.0.2'}}] +>>> JSONPath("$.book[1:-1]").parse(data) +[{'category': 'fiction', 'author': 'Evelyn Waugh', 'title': 'Sword of Honour', 'price': 12.99, 'brand': {'version': 'v0.0.1'}}, {'category': 'fiction', 'author': 'Herman Melville', 'title': 'Moby Dick', 'isbn': '0-553-21311-3', 'price': 8.99, 'brand': {'version': 'v1.0.2'}}] +>>> JSONPath("$.book[0:-1:2]").parse(data) +[{'category': 'reference', 'author': 'Nigel Rees', 'title': 'Sayings of the Century', 'price': 8.95, 'brand': {'version': 'v1.0.0'}}, {'category': 'fiction', 'author': 'Herman Melville', 'title': 'Moby Dick', 'isbn': '0-553-21311-3', 'price': 8.99, 'brand': {'version': 'v1.0.2'}}] +>>> JSONPath("$.book[-1:1]").parse(data) +[] +>>> JSONPath("$.book[-1:-11:3]").parse(data) +[] +>>> JSONPath("$.book[:]").parse(data) +[{'category': 'reference', 'author': 'Nigel Rees', 'title': 'Sayings of the Century', 'price': 8.95, 'brand': {'version': 'v1.0.0'}}, {'category': 'fiction', 'author': 'Evelyn Waugh', 'title': 'Sword of Honour', 'price': 12.99, 'brand': {'version': 'v0.0.1'}}, {'category': 'fiction', 'author': 'Herman Melville', 'title': 'Moby Dick', 'isbn': '0-553-21311-3', 'price': 8.99, 'brand': {'version': 'v1.0.2'}}, {'category': 'fiction', 'author': 'J. R. R. Tolkien', 'title': 'The Lord of the Rings', 'isbn': '0-395-19395-8', 'price': 22.99, 'brand': {'version': 'v1.0.3'}}] +>>> JSONPath("$.book[::-1]").parse(data) +[{'category': 'fiction', 'author': 'J. R. R. Tolkien', 'title': 'The Lord of the Rings', 'isbn': '0-395-19395-8', 'price': 22.99, 'brand': {'version': 'v1.0.3'}}, {'category': 'fiction', 'author': 'Herman Melville', 'title': 'Moby Dick', 'isbn': '0-553-21311-3', 'price': 8.99, 'brand': {'version': 'v1.0.2'}}, {'category': 'fiction', 'author': 'Evelyn Waugh', 'title': 'Sword of Honour', 'price': 12.99, 'brand': {'version': 'v0.0.1'}}, {'category': 'reference', 'author': 'Nigel Rees', 'title': 'Sayings of the Century', 'price': 8.95, 'brand': {'version': 'v1.0.0'}}] + +``` + +#### Filter Expression + +Support all python comparison operators (`==`, `!=`, `<`, `>`, `>=`, `<=`), python membership operators (`in`, `not in`), python logical operators (`and`, `or`, `not`). + +```python +>>> JSONPath("$.book[?(@.price>8 and @.price<9)].price").parse(data) +[8.95, 8.99] +>>> JSONPath('$.book[?(@.category=="reference")].category').parse(data) +['reference'] +>>> JSONPath('$.book[?(@.category!="reference" and @.price<9)].title').parse(data) +['Moby Dick'] +>>> JSONPath('$.book[?(@.author=="Herman Melville" or @.author=="Evelyn Waugh")].author').parse(data) +['Evelyn Waugh', 'Herman Melville'] +``` + +`Note`: You must use double quote(`""`) instead of single quote(`''`) to wrap the compared string, because single quote(`''`) has another usage in this JSONPath syntax . + +#### Sorter Expression + +Support sorting by multiple fields (using operator `,`) and reverse sort (using operator `~`). + +```python +>>> JSONPath("$.book[/(price)].price").parse(data) +[8.95, 8.99, 12.99, 22.99] +>>> JSONPath("$.book[/(~price)].price").parse(data) +[22.99, 12.99, 8.99, 8.95] +>>> JSONPath("$.book[/(category,price)].price").parse(data) +[8.99, 12.99, 22.99, 8.95] +>>> JSONPath("$.book[/(brand.version)].brand.version").parse(data) +['v0.0.1', 'v1.0.0', 'v1.0.2', 'v1.0.3'] +>>> JSONPath("$.scores[/(score)].score").parse(data) +[60, 85, 90, 95, 100] +``` + +#### Field-Extractor Expression + +Using `(field1,field2,…,filedn)` after a dict object to extract its fields. + +```python +>>> JSONPath("$.scores[/(score)].(score)").parse(data) +[{'score': 60}, {'score': 85}, {'score': 90}, {'score': 95}, {'score': 100}] +>>> JSONPath("$.book[/(category,price)].(title,price)").parse(data) +[{'title': 'Moby Dick', 'price': 8.99}, {'title': 'Sword of Honour', 'price': 12.99}, {'title': 'The Lord of the Rings', 'price': 22.99}, {'title': 'Sayings of the Century', 'price': 8.95}] +``` + +### Appendix: Example JSON data: + +```python +data = { + "a.b c": "a.b c", + "book": [ + { + "category": "reference", + "author": "Nigel Rees", + "title": "Sayings of the Century", + "price": 8.95, + "brand": { + "version": "v1.0.0" + } + }, + { + "category": "fiction", + "author": "Evelyn Waugh", + "title": "Sword of Honour", + "price": 12.99, + "brand": { + "version": "v0.0.1" + } + }, + { + "category": "fiction", + "author": "Herman Melville", + "title": "Moby Dick", + "isbn": "0-553-21311-3", + "price": 8.99, + "brand": { + "version": "v1.0.2" + } + }, + { + "category": "fiction", + "author": "J. R. R. Tolkien", + "title": "The Lord of the Rings", + "isbn": "0-395-19395-8", + "price": 22.99, + "brand": { + "version": "v1.0.3" + } + } + ], + "bicycle": { + "color": "red", + "price": 19.95 + }, + "scores": { + "math": { + "score": 100, + "avg": 60 + }, + "english": { + "score": 95, + "avg": 80 + }, + "physic": { + "score": 90, + "avg": 70 + }, + "chemistry": { + "score": 85, + "avg": 80 + }, + "chinese": { + "score": 60, + "avg": 75 + } + } +} +``` + +## Todo List + +- Syntax and character set (refer to k8s) + +> The name segment is required and must be 63 characters or less, beginning and ending with an alphanumeric character (`[a-z0-9A-Z]`) with dashes (`-`), underscores (`_`), dots (`.`), and alphanumerics between. + + diff --git a/.venv/lib/python3.12/site-packages/jsonpath_python-1.0.6.dist-info/RECORD b/.venv/lib/python3.12/site-packages/jsonpath_python-1.0.6.dist-info/RECORD new file mode 100644 index 00000000..f9366444 --- /dev/null +++ b/.venv/lib/python3.12/site-packages/jsonpath_python-1.0.6.dist-info/RECORD @@ -0,0 +1,8 @@ +jsonpath/__init__.py,sha256=V52DoUvzn4C_VgWnAokObGPZoXMl47VhZ1WgJ8Auf5A,10237
+jsonpath/__pycache__/__init__.cpython-312.pyc,,
+jsonpath_python-1.0.6.dist-info/INSTALLER,sha256=zuuue4knoyJ-UwPPXg8fezS7VCrXJQrAP7zeNuwvFQg,4
+jsonpath_python-1.0.6.dist-info/LICENSE,sha256=m9-3NsQ4khSvQABoIAeQobxwxyjJOB8_7RQiimjGNFw,1070
+jsonpath_python-1.0.6.dist-info/METADATA,sha256=5Szdz2wYOH34H4tzNAJmcBZrHdnBqTqYjWxGqMiJH3w,12160
+jsonpath_python-1.0.6.dist-info/RECORD,,
+jsonpath_python-1.0.6.dist-info/WHEEL,sha256=G16H4A3IeoQmnOrYV4ueZGKSjhipXx8zc8nu9FGlvMA,92
+jsonpath_python-1.0.6.dist-info/top_level.txt,sha256=Y35ncAqub-zO_G0jqXzw3Ll5rFBzSZXyJBWl7LAxmnM,9
diff --git a/.venv/lib/python3.12/site-packages/jsonpath_python-1.0.6.dist-info/WHEEL b/.venv/lib/python3.12/site-packages/jsonpath_python-1.0.6.dist-info/WHEEL new file mode 100644 index 00000000..becc9a66 --- /dev/null +++ b/.venv/lib/python3.12/site-packages/jsonpath_python-1.0.6.dist-info/WHEEL @@ -0,0 +1,5 @@ +Wheel-Version: 1.0 +Generator: bdist_wheel (0.37.1) +Root-Is-Purelib: true +Tag: py3-none-any + diff --git a/.venv/lib/python3.12/site-packages/jsonpath_python-1.0.6.dist-info/top_level.txt b/.venv/lib/python3.12/site-packages/jsonpath_python-1.0.6.dist-info/top_level.txt new file mode 100644 index 00000000..feca32d4 --- /dev/null +++ b/.venv/lib/python3.12/site-packages/jsonpath_python-1.0.6.dist-info/top_level.txt @@ -0,0 +1 @@ +jsonpath |