@@ -128,3 +128,36 @@ fun main(): Unit {
128128{"name":"Arrow","address":{"city":"Functional Town","street":{"number":1337,"name":"Functional street"}},"employees":[{"name":"JOHN","lastName":"doe"},{"name":"JANE","lastName":"doe"}]}
129129[JOHN, JANE]
130130```
131+
132+ Alternatively we can also use the _ pathEvery_ function to select _ every_ ` JsonElement ` in our ` JsonArray ` .
133+ Like for _ path_ we can also use the _ dot (.) notation_ to select deeply nested properties.
134+ On the other hand, the _ star (* ) notation_ allow us to select _ every_ ` JsonElement ` in our ` JsonArray ` .
135+
136+ Like before, below we select the _ employees_ ` JsonArray ` ,
137+ and then we select _ every_ ` JsonElement ` in the ` JsonArray ` .
138+ We then _ select_ the _ name_ out of _ every_ ` JsonElement ` .
139+
140+ Again, instead of ` Optional<JsonElement, String> ` it now returns ` Every<JsonElement, String> ` ,
141+ since we selected _ many properties_ instead of a _ single property_ .
142+
143+ You can then, apply a function to it using _ modify_ like before.
144+
145+ <!-- - TEST -->
146+
147+ <!-- - INCLUDE
148+ fun main(): Unit {
149+ ----- SUFFIX
150+ }
151+ -->
152+ ``` kotlin
153+ val json: JsonElement = Json .decodeFromString(JSON_STRING )
154+ val employeesName: Every <JsonElement , String > = JsonPath .pathEvery(" employees.*.name" ).string
155+ val res: JsonElement = employeesName.modify(json, String ::uppercase).also (::println)
156+ employeesName.getAll(res).also (::println)
157+ ```
158+ > You can get the full code [ here] ( src/jvmTest/kotlin/example/example-readme-03.kt ) .
159+
160+ ``` text
161+ {"name":"Arrow","address":{"city":"Functional Town","street":{"number":1337,"name":"Functional street"}},"employees":[{"name":"JOHN","lastName":"doe"},{"name":"JANE","lastName":"doe"}]}
162+ [JOHN, JANE]
163+ ```
0 commit comments