@@ -93,14 +93,44 @@ Documentation: [https://github.com/lateapexearlyspeed/Lateapexearlyspeed.JsonSch
93
93
Install via NuGet:
94
94
95
95
``` text
96
- dotnet add package LateApexEarlySpeed.Json.Schema
96
+ dotnet add package JsonQuery.Net
97
97
```
98
98
99
99
Usage:
100
100
101
- ``` dotnet
102
- IJsonQueryable queryable = JsonQueryable.Parse(jsonQuery);
103
- JsonNode? result = queryable.Query(jsonData);
101
+ ``` csharp
102
+ using JsonQuery .Net .Queryables ;
103
+
104
+ JsonNode jsonData = JsonNode .Parse ("""
105
+ {
106
+ "friends": [
107
+ { "name": "Chris", "age": 23, "city": "New York" },
108
+ { "name": "Emily", "age": 19, "city": "Atlanta" },
109
+ { "name": "Joe", "age": 32, "city": "New York" },
110
+ { "name": "Kevin", "age": 19, "city": "Atlanta" },
111
+ { "name": "Michelle", "age": 27, "city": "Los Angeles" },
112
+ { "name": "Robert", "age": 45, "city": "Manhattan" },
113
+ { "name": "Sarah", "age": 31, "city": "New York" }
114
+ ]
115
+ }
116
+ """ )! ;
117
+
118
+ // Get the array containing the friends from the object, filter the friends that live in New York,
119
+ // sort them by age, and pick just the name and age out of the objects.
120
+ IJsonQueryable jsonQueryable = JsonQueryable .Parse ("""
121
+ .friends
122
+ | filter(.city == "New York")
123
+ | sort(.age)
124
+ | pick(.name, .age)
125
+ """ );
126
+
127
+ JsonNode output = jsonQueryable .Query (jsonData )! ;
128
+
129
+ // output = [
130
+ // { "name": "Chris", "age": 23 },
131
+ // { "name": "Sarah", "age": 31 },
132
+ // { "name": "Joe", "age": 32 }
133
+ // ]
104
134
```
105
135
106
136
## How to implement in a new language
0 commit comments