From cd8c528c6694a5d37ecb04da3dbbd597e7e1336c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Viktor=20Djupsj=C3=B6backa?= Date: Sun, 10 Sep 2023 23:52:01 +0300 Subject: [PATCH] Add exception catching to usage section in README --- README.md | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 345da0a..cec9962 100644 --- a/README.md +++ b/README.md @@ -61,12 +61,18 @@ $ sudo service php-fpm restart ```php find($data, $selector); +$jsonPath = new JsonPath(); +try { + // Query a data array using a JSONPath expression string. + // Returns an array of matching elements, or false if nothing was found. + $result = $jsonPath->find($data, $selector); +} catch (JsonPathException $exception) { + echo $exception->getMessage(); // Usually a syntax error in the selector +} ``` ## Examples