@@ -30,9 +30,9 @@ You can install the component in your project using Composer:
30
30
Usage
31
31
-----
32
32
33
- To start querying a JSON document, first create a
34
- :class: ` Symfony \\ Component \\ JsonPath \\ JsonCrawler` object from a JSON string. The
35
- following examples use this sample "bookstore" JSON data::
33
+ To start querying a JSON document, first create a :class: ` Symfony \\ Component \\ JsonPath \\ JsonCrawler `
34
+ object from a JSON string. The following examples use this sample "bookstore"
35
+ JSON data::
36
36
37
37
use Symfony\Component\JsonPath\JsonCrawler;
38
38
@@ -77,9 +77,8 @@ following examples use this sample "bookstore" JSON data::
77
77
78
78
$crawler = new JsonCrawler($json);
79
79
80
- Once you have the crawler instance, use its
81
- :method:`Symfony\\ Component\\ JsonPath\\ JsonCrawler::find ` method to start
82
- querying the data. This method returns an array of matching values.
80
+ Once you have the crawler instance, use its :method: `Symfony\\ Component\\ JsonPath\\ JsonCrawler::find `
81
+ method to start querying the data. This method returns an array of matching values.
83
82
84
83
Querying with Expressions
85
84
-------------------------
@@ -120,12 +119,7 @@ you to find values without specifying the full path::
120
119
// get all authors from anywhere in the document
121
120
$authors = $crawler->find('$..author');
122
121
123
- // $authors is equals to [
124
- 'Nigel Rees',
125
- 'Evelyn Waugh',
126
- 'Herman Melville',
127
- 'John Ronald Reuel Tolkien'
128
- ]
122
+ // $authors is ['Nigel Rees', 'Evelyn Waugh', 'Herman Melville', 'John Ronald Reuel Tolkien']
129
123
130
124
Filtering Results
131
125
~~~~~~~~~~~~~~~~~
@@ -141,9 +135,8 @@ Building Queries Programmatically
141
135
142
136
For more dynamic or complex query building, use the fluent API provided
143
137
by the :class: `Symfony\\ Component\\ JsonPath\\ JsonPath ` class. This lets you
144
- construct a query object step by step. The ``JsonPath `` object can then be
145
- passed to the crawler's
146
- :method: `Symfony\\ Component\\ JsonPath\\ JsonCrawler::find ` method.
138
+ construct a query object step by step. The ``JsonPath `` object can then be passed
139
+ to the crawler's :method: `Symfony\\ Component\\ JsonPath\\ JsonCrawler::find ` method.
147
140
148
141
The main advantage of the programmatic builder is that it automatically handles
149
142
escaping of keys and values, preventing syntax errors::
@@ -225,8 +218,7 @@ Testing with JSON Assertions
225
218
----------------------------
226
219
227
220
The component provides a set of PHPUnit assertions to make testing JSON data
228
- more convenient. Use the
229
- :class: `Symfony\\ Component\\ JsonPath\\ Test\\ JsonPathAssertionsTrait `
221
+ more convenient. Use the :class: `Symfony\\ Component\\ JsonPath\\ Test\\ JsonPathAssertionsTrait `
230
222
in your test class::
231
223
232
224
use PHPUnit\Framework\TestCase;
@@ -308,11 +300,9 @@ Error Handling
308
300
The component throws specific exceptions for invalid input or queries:
309
301
310
302
* :class: `Symfony\\ Component\\ JsonPath\\ Exception\\ InvalidArgumentException `:
311
- Thrown if the input to the ``JsonCrawler `` constructor is not a valid JSON
312
- string;
303
+ Thrown if the input to the ``JsonCrawler `` constructor is not a valid JSON string;
313
304
* :class: `Symfony\\ Component\\ JsonPath\\ Exception\\ InvalidJsonStringInputException `:
314
- Thrown during a ``find() `` call if the JSON string is malformed
315
- (e.g., syntax error);
305
+ Thrown during a ``find() `` call if the JSON string is malformed (e.g., syntax error);
316
306
* :class: `Symfony\\ Component\\ JsonPath\\ Exception\\ JsonCrawlerException `:
317
307
Thrown for errors within the JsonPath expression itself, such as using an
318
308
unknown function
0 commit comments