csonpath 0.0.1__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
csonpath-0.0.1/LICENSE ADDED
@@ -0,0 +1,28 @@
1
+ BSD 3-Clause License
2
+
3
+ Copyright (c) 2025, Outscale
4
+
5
+ Redistribution and use in source and binary forms, with or without
6
+ modification, are permitted provided that the following conditions are met:
7
+
8
+ 1. Redistributions of source code must retain the above copyright notice, this
9
+ list of conditions and the following disclaimer.
10
+
11
+ 2. Redistributions in binary form must reproduce the above copyright notice,
12
+ this list of conditions and the following disclaimer in the documentation
13
+ and/or other materials provided with the distribution.
14
+
15
+ 3. Neither the name of the copyright holder nor the names of its
16
+ contributors may be used to endorse or promote products derived from
17
+ this software without specific prior written permission.
18
+
19
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
20
+ AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
22
+ DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
23
+ FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24
+ DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
25
+ SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
26
+ CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
27
+ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28
+ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
@@ -0,0 +1,2 @@
1
+ include csonpath.h
2
+ include csonpath_do.h
@@ -0,0 +1,7 @@
1
+ Metadata-Version: 2.4
2
+ Name: csonpath
3
+ Version: 0.0.1
4
+ License-File: LICENSE
5
+ Provides-Extra: dev
6
+ Requires-Dist: pytest>=8.3.5; extra == "dev"
7
+ Dynamic: license-file
@@ -0,0 +1,106 @@
1
+ # csonpath
2
+
3
+ > that's not my path, that's not your path, but csonpath
4
+
5
+ [![Project Sandbox](https://docs.outscale.com/fr/userguide/_images/Project-Sandbox-yellow.svg)](https://docs.outscale.com/en/userguide/Open-Source-Projects.html)
6
+
7
+ **csonpath** is a partial [JSONPath](https://goessner.net/articles/JsonPath/) implementation in C, with Python bindings. It allows you to query, update, and remove data from JSON objects using path expressions.
8
+
9
+ ## 🌐 Links
10
+
11
+ - Project website: https://github.com/outscale/csonpath
12
+ - Join our community on [Discord](https://discord.gg/HUVtY5gT6s)
13
+
14
+
15
+ ## πŸ“„ Table of Contents
16
+
17
+ - [Overview](#-overview)
18
+ - [Requirements](#-requirements)
19
+ - [Installation](#-installation)
20
+ - [Configuration](#-configuration)
21
+ - [Usage](#-usage)
22
+ - [Examples](#-examples)
23
+ - [License](#-license)
24
+ - [Contributing](#-contributing)
25
+
26
+
27
+ ## πŸš€ Features
28
+
29
+ - **Find First**: Retrieve the first value matching a path.
30
+ - **Find All**: Retrieve all values matching a path.
31
+ - **Update or Create**: Update values or create new ones according to the path.
32
+ - **Remove**: Remove values matching a path.
33
+ - **Update or Create Callback**: Update values or create new ones according to the path, using a user-define callback.
34
+ - **Callback**: Call a callback according to the path.
35
+ - **Supports both C (using json-c) and Python objects.**
36
+
37
+ ## βœ… Getting Started
38
+
39
+ ### Prerequisites
40
+
41
+ - C compiler (gcc/clang)
42
+ - [json-c](https://github.com/json-c/json-c) library for C usage
43
+ - Python 3.x (for Python bindings)
44
+
45
+ ### Build
46
+
47
+ To build the C tests and examples:
48
+
49
+ ```sh
50
+ make
51
+ ```
52
+
53
+ ### Usage (json-c)
54
+
55
+ See examples in [`tests/json-c/get-a.c`](tests/json-c/get-a.c):
56
+
57
+ ```c
58
+ #include "csonpath_json-c.h"
59
+
60
+ const char *json_str = "{ \"a\": \"value\", \"array\": [1,2,3] }";
61
+ struct csonpath p;
62
+ struct json_object *jobj = json_tokener_parse(json_str);
63
+ struct json_object *ret;
64
+
65
+ csonpath_init(&p, "$.a");
66
+ ret = csonpath_find_first(&p, jobj);
67
+ // ret now points to "value"
68
+ ```
69
+
70
+ ### Usage (Python)
71
+
72
+ Check [`dump-test.py`](dump-test.py) for examples:
73
+
74
+ ```python
75
+ import csonpath
76
+
77
+ d = { "a": "value", "array": [1,2,3] }
78
+ o = csonpath.CsonPath("$.a")
79
+ print(o.find_first(d)) # Output: "value"
80
+ ```
81
+
82
+ ### Backends and Direct Usage
83
+
84
+ csonpath is inspired by JSONPath, but is designed to be backend-agnostic: it can work with any C library or environment that manipulates array, object, and scalar typesβ€”not just JSON. Out of the box, backends for Python and json-c are provided, but you can create your own backend for other formats such as YAML, or any custom data structure.
85
+
86
+ To use csonpath with a different data type or library, simply define the required macros and types in a header file (similar to `csonpath_json-c.h` or `csonpath_python.c`), then include your backend header before `csonpath.h`. This approach allows you to adapt csonpath for manipulating data in any format that supports array/object semantics, giving you full flexibility beyond just JSON.
87
+
88
+ ## Directory Structure
89
+
90
+ - `csonpath.h`, `csonpath_do.h` - Main implementation files
91
+ - `csonpath_json-c.h` - Json-C implementation, use it by including "csonpath_json-c.h" directly in your source
92
+ - `csonpath_python.c` - python implementation, use it like a python lib (so `pip install .`)
93
+ - `tests/` - Contains tests
94
+ - `bench//` - Some benchmarks
95
+
96
+ ## 🀝 Contributing
97
+
98
+ We welcome contributions!
99
+
100
+ Please read our [Contributing Guidelines](CONTRIBUTING.md) and [Code of Conduct](CODE_OF_CONDUCT.md) before submitting a pull request.
101
+
102
+ Feel free to open issues or pull requests!
103
+
104
+ ## πŸ“œ License
105
+ BSD 3-Clause. See [LICENSE](LICENSE).
106
+
@@ -0,0 +1,7 @@
1
+ Metadata-Version: 2.4
2
+ Name: csonpath
3
+ Version: 0.0.1
4
+ License-File: LICENSE
5
+ Provides-Extra: dev
6
+ Requires-Dist: pytest>=8.3.5; extra == "dev"
7
+ Dynamic: license-file
@@ -0,0 +1,12 @@
1
+ LICENSE
2
+ MANIFEST.in
3
+ README.md
4
+ csonpath.h
5
+ csonpath_do.h
6
+ csonpath_python.c
7
+ pyproject.toml
8
+ csonpath.egg-info/PKG-INFO
9
+ csonpath.egg-info/SOURCES.txt
10
+ csonpath.egg-info/dependency_links.txt
11
+ csonpath.egg-info/requires.txt
12
+ csonpath.egg-info/top_level.txt
@@ -0,0 +1,3 @@
1
+
2
+ [dev]
3
+ pytest>=8.3.5
@@ -0,0 +1 @@
1
+ csonpath