Skip to content

Commit 2d1d0f2

Browse files
committed
Merge branch 'main' into develop
2 parents 84dbbb0 + 3279ec7 commit 2d1d0f2

3 files changed

Lines changed: 16 additions & 146 deletions

File tree

docs/jsonpatch.md

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,15 @@ nav_order: 2
66

77
# Hyperbee JsonPatch
88

9-
Hyperbee JsonPatch is a high-performance library for applying JSON patches to JSON documents, as defined in [RFC 6902](https://www.rfc-editor.org/rfc/rfc6902.html). It supports both `JsonElement` and `JsonNode`, allowing for efficient and flexible modifications of JSON data.
9+
Hyperbee JsonPatch is a high-performance library for applying JSON patches to JSON documents, as defined in [RFC 6902](https://www.rfc-editor.org/rfc/rfc6902.html).
10+
It supports both `JsonElement` and `JsonNode`, allowing for efficient and flexible modifications of JSON data.
1011

1112
## Features
1213

13-
- **High Performance:** Optimized for speed and low memory allocations.
14-
- **Supports:** `JsonElement` and `JsonNode`.
15-
- **RFC Conformance:** Fully adheres to RFC 6902 for reliable behavior.
14+
- **High Performance:** Optimized for speed and efficiency.
15+
- **Low Memory Allocations:** Designed to minimize memory usage.
16+
- **Conformance:** Fully adheres to RFC 6902 for JSON Patch.
17+
- **Supports both `JsonElement` and `JsonNode`:** Works seamlessly with both JSON document types.
1618

1719
## Usage
1820

@@ -40,9 +42,9 @@ var patch = """
4042
""";
4143

4244
var document = JsonDocument.Parse( json );
43-
var jsonPath = JsonSerializer.Deserialize<JsonPatch>( patch );
45+
var jsonPatch = JsonSerializer.Deserialize<JsonPatch>( patch );
4446

45-
jsonPath.Apply( document.RootElement, out var node ); // Apply updates a JsonNode (since elements cannot be modified)
47+
jsonPatch.Apply( document.RootElement, out var node ); // Apply updates a JsonNode (since elements cannot be modified)
4648
4749
var value = JsonPathPointer<JsonNode>.FromPointer( node, "/store/book/0/title" );
4850
Console.WriteLine( value ); // Output: "New Book"
@@ -72,9 +74,9 @@ var patch = """
7274
""";
7375

7476
var node = JsonNode.Parse( json );
75-
var jsonPath = JsonSerializer.Deserialize<JsonPatch>( patch );
77+
var jsonPatch = JsonSerializer.Deserialize<JsonPatch>( patch );
7678

77-
jsonPath.Apply( node ); // Apply modifies the JsonNode in place (does rollback changes if an error occurs)
79+
jsonPatch.Apply( node ); // Apply modifies the JsonNode in place (does rollback changes if an error occurs)
7880
7981
var value = JsonPathPointer<JsonNode>.FromPointer( node, "/store/book/0/title" );
8082
Console.WriteLine( value ); // Output: "New Book"
@@ -117,8 +119,3 @@ var patch = JsonSerializer.Serialize( patchOperations );
117119
Console.WriteLine( patch ); // Output: [{"op":"add","path":"/last","value":"Doe"}]
118120
```
119121

120-
## Why Choose Hyperbee JsonPatch?
121-
122-
- **Fast and Efficient:** Designed for high performance and low memory usage.
123-
- **Versatile:** Works seamlessly with both `JsonElement` and `JsonNode`.
124-
- **Standards Compliant:** Adheres strictly to RFC 6902 for JSON Patch.

docs/jsonpath/overview.md

Lines changed: 1 addition & 123 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ nav_order: 1
1010
Hyperbee JsonPath is a high-performance JSONPath parser for `System.Text.Json`, that supports both `JsonElement` and `JsonNode`.
1111
The library is designed to be fast and extensible, allowing support for other JSON document types and functions.
1212

13-
## Why Choose Hyperbee JsonPath?
13+
## Features
1414

1515
Hyperbee is fast, lightweight, fully RFC-9535 conforming, and supports **both** `JsonElement` and `JsonNode`.
1616

@@ -97,125 +97,3 @@ Console.WriteLine(path); // Output: "$.store.book[0].category"
9797
9898
```
9999

100-
101-
## Comparison with Other Libraries
102-
103-
There are other excellent libraries .NET JsonPath.
104-
105-
### [JsonPath.Net](https://docs.json-everything.net/path/basics/) Json-Everything
106-
107-
- **Pros:**
108-
- Comprehensive feature set.
109-
- Deferred execution queries with `IEnumerable`.
110-
- Enhanced JsonPath syntax.
111-
- Strong community support.
112-
113-
- **Cons:**
114-
- No support for `JsonElement`.
115-
- More memory intensive.
116-
- Not quite as fast as other implementations.
117-
118-
### [JsonCons.NET](https://danielaparker.github.io/JsonCons.Net/articles/JsonPath/JsonConsJsonPath.html)
119-
120-
- **Pros:**
121-
- High performance.
122-
- Enhanced JsonPath syntax.
123-
124-
- **Cons:**
125-
- No support for `JsonNode`.
126-
- Does not return an `IEnumerable` result (no defered query execution).
127-
128-
### [Json.NET](https://www.newtonsoft.com/json) Newtonsoft
129-
130-
- **Pros:**
131-
- Comprehensive feature set.
132-
- Deferred execution queries with `IEnumerable`.
133-
- Documentation and examples.
134-
- Strong community support.
135-
136-
- **Cons:**
137-
- No support for `JsonElement`, or `JsonNode`.
138-
139-
## Benchmarks
140-
141-
Here is a performance comparison of various queries on the standard book store document.
142-
143-
```json
144-
{
145-
"store": {
146-
"book": [
147-
{
148-
"category": "reference",
149-
"author": "Nigel Rees",
150-
"title": "Sayings of the Century",
151-
"price": 8.95
152-
},
153-
{
154-
"category": "fiction",
155-
"author": "Evelyn Waugh",
156-
"title": "Sword of Honour",
157-
"price": 12.99
158-
},
159-
{
160-
"category": "fiction",
161-
"author": "Herman Melville",
162-
"title": "Moby Dick",
163-
"isbn": "0-553-21311-3",
164-
"price": 8.99
165-
},
166-
{
167-
"category": "fiction",
168-
"author": "J. R. R. Tolkien",
169-
"title": "The Lord of the Rings",
170-
"isbn": "0-395-19395-8",
171-
"price": 22.99
172-
}
173-
],
174-
"bicycle": {
175-
"color": "red",
176-
"price": 19.95
177-
}
178-
}
179-
}
180-
```
181-
182-
| Method | Mean | Error | StdDev | Allocated
183-
| :----------------------- | ---------: | ----------: | ---------: | ---------:
184-
| `$..* First()`
185-
| Hyperbee_JsonElement | 2.874 μs | 1.6256 μs | 0.0891 μs | 3.52 KB
186-
| Hyperbee_JsonNode | 3.173 μs | 0.7979 μs | 0.0437 μs | 3.09 KB
187-
| JsonEverything_JsonNode | 3.199 μs | 2.4697 μs | 0.1354 μs | 3.53 KB
188-
| JsonCons_JsonElement | 5.976 μs | 8.4042 μs | 0.4607 μs | 8.48 KB
189-
| Newtonsoft_JObject | 9.219 μs | 2.9245 μs | 0.1603 μs | 14.22 KB
190-
| | | | |
191-
| `$..*`
192-
| JsonCons_JsonElement | 5.674 μs | 3.8650 μs | 0.2119 μs | 8.45 KB
193-
| Hyperbee_JsonElement | 7.934 μs | 3.5907 μs | 0.1968 μs | 9.13 KB
194-
| Hyperbee_JsonNode | 10.457 μs | 7.7120 μs | 0.4227 μs | 10.91 KB
195-
| Newtonsoft_JObject | 10.722 μs | 4.1310 μs | 0.2264 μs | 14.86 KB
196-
| JsonEverything_JsonNode | 23.096 μs | 10.8629 μs | 0.5954 μs | 36.81 KB
197-
| | | | |
198-
| `$..price`
199-
| Hyperbee_JsonElement | 4.428 μs | 4.6731 μs | 0.2561 μs | 4.2 KB
200-
| JsonCons_JsonElement | 5.355 μs | 1.1624 μs | 0.0637 μs | 5.65 KB
201-
| Hyperbee_JsonNode | 7.931 μs | 0.6970 μs | 0.0382 μs | 7.48 KB
202-
| Newtonsoft_JObject | 10.334 μs | 8.2331 μs | 0.4513 μs | 14.4 KB
203-
| JsonEverything_JsonNode | 17.000 μs | 14.9812 μs | 0.8212 μs | 27.63 KB
204-
| | | | |
205-
| `$.store.book[?(@.price == 8.99)]`
206-
| Hyperbee_JsonElement | 4.153 μs | 3.6089 μs | 0.1978 μs | 5.24 KB
207-
| JsonCons_JsonElement | 4.873 μs | 1.0395 μs | 0.0570 μs | 5.05 KB
208-
| Hyperbee_JsonNode | 6.980 μs | 5.1007 μs | 0.2796 μs | 8 KB
209-
| Newtonsoft_JObject | 10.629 μs | 3.9096 μs | 0.2143 μs | 15.84 KB
210-
| JsonEverything_JsonNode | 11.133 μs | 7.2544 μs | 0.3976 μs | 15.85 KB
211-
| | | | |
212-
| `$.store.book[0]`
213-
| Hyperbee_JsonElement | 2.677 μs | 2.2733 μs | 0.1246 μs | 2.27 KB
214-
| Hyperbee_JsonNode | 3.126 μs | 3.5345 μs | 0.1937 μs | 2.77 KB
215-
| JsonCons_JsonElement | 3.229 μs | 0.0681 μs | 0.0037 μs | 3.21 KB
216-
| JsonEverything_JsonNode | 4.612 μs | 2.0037 μs | 0.1098 μs | 5.96 KB
217-
| Newtonsoft_JObject | 9.627 μs | 1.1498 μs | 0.0630 μs | 14.56 KB
218-
219-
## Additional Documentation
220-
221-
Additional documentation for [JsonPath syntax can be found here](jsonpath-syntax).

docs/jsonpointer.md

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,15 @@ nav_order: 3
66

77
# Hyperbee JsonPointer
88

9-
Hyperbee JsonPointer provides a simple and efficient way to navigate JSON documents using pointer syntax, as defined in [RFC 6901](https://www.rfc-editor.org/rfc/rfc6901.html). It supports both `JsonElement` and `JsonNode`, making it a versatile tool for JSON manipulation in .NET.
9+
Hyperbee JsonPointer provides a simple and efficient way to navigate JSON documents using pointer syntax, as defined in [RFC 6901](https://www.rfc-editor.org/rfc/rfc6901.html).
10+
It supports both `JsonElement` and `JsonNode`, making it a versatile tool for JSON manipulation in .NET.
1011

1112
## Features
1213

1314
- **High Performance:** Optimized for speed and efficiency.
14-
- **Supports:** `JsonElement` and `JsonNode`.
15-
- **RFC Conformance:** Fully adheres to RFC 6901 for reliable behavior.
15+
- **Low Memory Allocations:** Designed to minimize memory usage.
16+
- **Conformance:** Fully adheres to RFC 6901 for JSON Pointer.
17+
- **Supports both `JsonElement` and `JsonNode`:** Works seamlessly with both JSON document types.
1618

1719
## Usage
1820

@@ -59,10 +61,3 @@ var value = JsonPointer<JsonNode>.FromPointer(node, "/store/book/1/category")
5961

6062
Console.WriteLine(value.GetValue<string>()); // Output: "science"
6163
```
62-
63-
## Why Choose Hyperbee JsonPointer?
64-
65-
- **Fast and Efficient:** Designed for high performance and low memory usage.
66-
- **Versatile:** Works seamlessly with both `JsonElement` and `JsonNode`.
67-
- **Standards Compliant:** Adheres strictly to RFC 6901 for JSON Pointer.
68-

0 commit comments

Comments
 (0)