{"id":14036742,"url":"https://github.com/SoftCreatR/JSONPath","last_synced_at":"2025-07-27T03:33:04.081Z","repository":{"id":44678015,"uuid":"302919629","full_name":"SoftCreatR/JSONPath","owner":"SoftCreatR","description":"JSONPath implementation for PHP.","archived":false,"fork":false,"pushed_at":"2025-03-26T08:11:33.000Z","size":273,"stargazers_count":157,"open_issues_count":22,"forks_count":28,"subscribers_count":5,"default_branch":"main","last_synced_at":"2025-05-29T01:59:22.434Z","etag":null,"topics":["filter","hacktoberfest","json","json-filtering","json-flattener","json-flattening","json-parser","json-parsing","json-path","jsonpath","parser","parsing","php","xpath"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/SoftCreatR.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE.md","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":"softcreatr","custom":["https://ecologi.com/softcreatr?r=61212ab3fc69b8eb8a2014f4"]}},"created_at":"2020-10-10T14:27:12.000Z","updated_at":"2025-05-21T05:46:08.000Z","dependencies_parsed_at":"2024-04-16T07:48:04.691Z","dependency_job_id":"f4c8b8f4-3bfe-490f-99b7-a3333d68dcf3","html_url":"https://github.com/SoftCreatR/JSONPath","commit_stats":{"total_commits":100,"total_committers":12,"mean_commits":8.333333333333334,"dds":"0.45999999999999996","last_synced_commit":"272173a65fd16b25010dbd54d04dd34c0c5a8500"},"previous_names":[],"tags_count":20,"template":false,"template_full_name":null,"purl":"pkg:github/SoftCreatR/JSONPath","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SoftCreatR%2FJSONPath","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SoftCreatR%2FJSONPath/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SoftCreatR%2FJSONPath/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SoftCreatR%2FJSONPath/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/SoftCreatR","download_url":"https://codeload.github.com/SoftCreatR/JSONPath/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SoftCreatR%2FJSONPath/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":267294180,"owners_count":24065343,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-07-27T02:00:11.917Z","response_time":82,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["filter","hacktoberfest","json","json-filtering","json-flattener","json-flattening","json-parser","json-parsing","json-path","jsonpath","parser","parsing","php","xpath"],"created_at":"2024-08-12T03:02:11.960Z","updated_at":"2025-07-27T03:32:59.067Z","avatar_url":"https://github.com/SoftCreatR.png","language":"PHP","readme":"# JSONPath for PHP 8.1+\n\n[![Build](https://img.shields.io/github/actions/workflow/status/SoftCreatR/JSONPath/.github/workflows/Test.yml?branch=main)](https://github.com/SoftCreatR/JSONPath/actions/workflows/Test.yml) [![Latest Release](https://img.shields.io/packagist/v/SoftCreatR/JSONPath?color=blue\u0026label=Latest%20Release)](https://packagist.org/packages/softcreatr/jsonpath)\n[![MIT licensed](https://img.shields.io/badge/license-MIT-blue.svg)](./LICENSE) [![Plant Tree](https://img.shields.io/badge/dynamic/json?color=brightgreen\u0026label=Plant%20Tree\u0026query=%24.total\u0026url=https%3A%2F%2Fpublic.offset.earth%2Fusers%2Fsoftcreatr%2Ftrees)](https://ecologi.com/softcreatr?r=61212ab3fc69b8eb8a2014f4)\n[![Codecov branch](https://img.shields.io/codecov/c/github/SoftCreatR/JSONPath)](https://codecov.io/gh/SoftCreatR/JSONPath)\n[![Code Climate maintainability](https://img.shields.io/codeclimate/maintainability-percentage/SoftCreatR/JSONPath)](https://codeclimate.com/github/SoftCreatR/JSONPath)\n\nThis is a [JSONPath](http://goessner.net/articles/JsonPath/) implementation for PHP based on Stefan Goessner's JSONPath script.\n\nJSONPath is an XPath-like expression language for filtering, flattening and extracting data.\n\nThis project aims to be a clean and simple implementation with the following goals:\n\n - Object-oriented code (should be easier to manage or extend in future)\n - Expressions are parsed into tokens using code inspired by the Doctrine Lexer. The tokens are cached internally to avoid re-parsing the expressions.\n - There is no `eval()` in use\n - Any combination of objects/arrays/ArrayAccess-objects can be used as the data input which is great if you're de-serializing JSON in to objects or if you want to process your own data structures.\n\n## Installation\n\n```bash\ncomposer require softcreatr/jsonpath:\"^0.9\"\n```\n\n## JSONPath Examples\n\nJSONPath                  | Result\n--------------------------|-------------------------------------\n`$.store.books[*].author` | the authors of all books in the store\n`$..author`               | all authors\n`$.store..price`          | the price of everything in the store.\n`$..books[2]`             | the third book\n`$..books[(@.length-1)]`  | the last book in order.\n`$..books[-1:]`           | the last book in order.\n`$..books[0,1]`           | the first two books\n`$..books[:2]`            | the first two books\n`$..books[::2]`           | every second book starting from first one\n`$..books[1:6:3]`         | every third book starting from 1 till 6\n`$..books[?(@.isbn)]`     | filter all books with isbn number\n`$..books[?(@.price\u003c10)]` | filter all books cheaper than 10\n`$..books.length`         | the amount of books\n`$..*`                    | all elements in the data (recursively extracted)\n\n\nExpression syntax\n---\n\nSymbol                | Description\n----------------------|-------------------------\n`$`                   | The root object/element (not strictly necessary)\n`@`                   | The current object/element\n`.` or `[]`           | Child operator\n`..`                  | Recursive descent\n`*`                   | Wildcard. All child elements regardless their index.\n`[,]`                 | Array indices as a set\n`[start:end:step]`    | Array slice operator borrowed from ES4/Python.\n`?()`                 | Filters a result set by a script expression\n`()`                  | Uses the result of a script expression as the index\n\n## PHP Usage\n\n#### Using arrays\n\n```php\n\u003c?php\nrequire_once __DIR__ . '/vendor/autoload.php';\n\n$data = ['people' =\u003e [\n    ['name' =\u003e 'Sascha'],\n    ['name' =\u003e 'Bianca'],\n    ['name' =\u003e 'Alexander'],\n    ['name' =\u003e 'Maximilian'],\n]];\n\nprint_r((new \\Flow\\JSONPath\\JSONPath($data))-\u003efind('$.people.*.name')-\u003egetData());\n\n/*\nArray\n(\n    [0] =\u003e Sascha\n    [1] =\u003e Bianca\n    [2] =\u003e Alexander\n    [3] =\u003e Maximilian\n)\n*/\n```\n\n#### Using objects\n\n```php\n\u003c?php\nrequire_once __DIR__ . '/vendor/autoload.php';\n\n$data = json_decode('{\"name\":\"Sascha Greuel\",\"birthdate\":\"1987-12-16\",\"city\":\"Gladbeck\",\"country\":\"Germany\"}', false);\n\nprint_r((new \\Flow\\JSONPath\\JSONPath($data))-\u003efind('$')-\u003egetData()[0]);\n\n/*\nstdClass Object\n(\n    [name] =\u003e Sascha Greuel\n    [birthdate] =\u003e 1987-12-16\n    [city] =\u003e Gladbeck\n    [country] =\u003e Germany\n)\n*/\n```\n\nMore examples can be found in the [Wiki](https://github.com/SoftCreatR/JSONPath/wiki/Queries)\n\n### Magic method access\n\nThe options flag `JSONPath::ALLOW_MAGIC` will instruct JSONPath when retrieving a value to first check if an object\nhas a magic `__get()` method and will call this method if available. This feature is *iffy* and\nnot very predictable as:\n\n-  wildcard and recursive features will only look at public properties and can't smell which properties are magically accessible\n-  there is no `property_exists` check for magic methods so an object with a magic `__get()` will always return `true` when checking\n   if the property exists\n-   any errors thrown or unpredictable behaviour caused by fetching via `__get()` is your own problem to deal with\n\n```php\nuse Flow\\JSONPath\\JSONPath;\n\n$myObject = (new Foo())-\u003eget('bar');\n$jsonPath = new JSONPath($myObject, JSONPath::ALLOW_MAGIC);\n```\n\nFor more examples, check the JSONPathTest.php tests file.\n\n## Script expressions\n\nScript expressions are not supported as the original author intended because:\n\n-   This would only be achievable through `eval` (boo).\n-   Using the script engine from different languages defeats the purpose of having a single expression evaluate the same way in different\n    languages which seems like a bit of a flaw if you're creating an abstract expression syntax.\n\nSo here are the types of query expressions that are supported:\n\n\t[?(@._KEY_ _OPERATOR_ _VALUE_)] // \u003c, \u003e, \u003c=, \u003e=, !=, ==, =~, in and nin\n\te.g.\n\t[?(@.title == \"A string\")] //\n\t[?(@.title = \"A string\")]\n\t// A single equals is not an assignment but the SQL-style of '=='\n\t[?(@.title =~ /^a(nother)? string$/i)]\n\t[?(@.title in [\"A string\", \"Another string\"])]\n\t[?(@.title nin [\"A string\", \"Another string\"])]\n\t\n## Known issues\n\n- This project has not implemented multiple string indexes e.g. `$[name,year]` or `$[\"name\",\"year\"]`. I have no ETA on that feature, and it would require some re-writing of the parser that uses a very basic regex implementation.\n\n## Similar projects\n\n[FlowCommunications/JSONPath](https://github.com/FlowCommunications/JSONPath) is the predecessor of this library by Stephen Frank\n\nOther / Similar implementations can be found in the [Wiki](https://github.com/SoftCreatR/JSONPath/wiki/Other-Implementations).\n\n## Changelog\n\nA list of changes can be found in the [CHANGELOG.md](CHANGELOG.md) file. \n\n## License 🌳\n\n[MIT](LICENSE.md) © [1-2.dev](https://1-2.dev)\n\nThis package is Treeware. If you use it in production, then we ask that you [**buy the world a tree**](https://ecologi.com/softcreatr?r=61212ab3fc69b8eb8a2014f4) to thank us for our work. By contributing to the ecologi project, you’ll be creating employment for local families and restoring wildlife habitats.\n\n## Contributors ✨\n\n\u003ctable\u003e\n\u003ctr\u003e\n    \u003ctd align=\"center\" style=\"word-wrap: break-word; width: 150.0; height: 150.0\"\u003e\n        \u003ca href=https://github.com/SoftCreatR\u003e\n            \u003cimg src=https://avatars.githubusercontent.com/u/81188?v=4 width=\"100;\"  alt=Sascha Greuel/\u003e\n            \u003cbr /\u003e\n            \u003csub style=\"font-size:14px\"\u003e\u003cb\u003eSascha Greuel\u003c/b\u003e\u003c/sub\u003e\n        \u003c/a\u003e\n    \u003c/td\u003e\n    \u003ctd align=\"center\" style=\"word-wrap: break-word; width: 150.0; height: 150.0\"\u003e\n        \u003ca href=https://github.com/Schrank\u003e\n            \u003cimg src=https://avatars.githubusercontent.com/u/379680?v=4 width=\"100;\"  alt=Fabian Blechschmidt/\u003e\n            \u003cbr /\u003e\n            \u003csub style=\"font-size:14px\"\u003e\u003cb\u003eFabian Blechschmidt\u003c/b\u003e\u003c/sub\u003e\n        \u003c/a\u003e\n    \u003c/td\u003e\n    \u003ctd align=\"center\" style=\"word-wrap: break-word; width: 150.0; height: 150.0\"\u003e\n        \u003ca href=https://github.com/warlof\u003e\n            \u003cimg src=https://avatars.githubusercontent.com/u/648753?v=4 width=\"100;\"  alt=Loïc Leuilliot/\u003e\n            \u003cbr /\u003e\n            \u003csub style=\"font-size:14px\"\u003e\u003cb\u003eLoïc Leuilliot\u003c/b\u003e\u003c/sub\u003e\n        \u003c/a\u003e\n    \u003c/td\u003e\n    \u003ctd align=\"center\" style=\"word-wrap: break-word; width: 150.0; height: 150.0\"\u003e\n        \u003ca href=https://github.com/SG5\u003e\n            \u003cimg src=https://avatars.githubusercontent.com/u/3931761?v=4 width=\"100;\"  alt=Sergey/\u003e\n            \u003cbr /\u003e\n            \u003csub style=\"font-size:14px\"\u003e\u003cb\u003eSergey\u003c/b\u003e\u003c/sub\u003e\n        \u003c/a\u003e\n    \u003c/td\u003e\n    \u003ctd align=\"center\" style=\"word-wrap: break-word; width: 150.0; height: 150.0\"\u003e\n        \u003ca href=https://github.com/drealecs\u003e\n            \u003cimg src=https://avatars.githubusercontent.com/u/209984?v=4 width=\"100;\"  alt=Alexandru Pătrănescu/\u003e\n            \u003cbr /\u003e\n            \u003csub style=\"font-size:14px\"\u003e\u003cb\u003eAlexandru Pătrănescu\u003c/b\u003e\u003c/sub\u003e\n        \u003c/a\u003e\n    \u003c/td\u003e\n    \u003ctd align=\"center\" style=\"word-wrap: break-word; width: 150.0; height: 150.0\"\u003e\n        \u003ca href=https://github.com/oleg-andreyev\u003e\n            \u003cimg src=https://avatars.githubusercontent.com/u/1244112?v=4 width=\"100;\"  alt=Oleg Andreyev/\u003e\n            \u003cbr /\u003e\n            \u003csub style=\"font-size:14px\"\u003e\u003cb\u003eOleg Andreyev\u003c/b\u003e\u003c/sub\u003e\n        \u003c/a\u003e\n    \u003c/td\u003e\n\u003c/tr\u003e\n\u003ctr\u003e\n    \u003ctd align=\"center\" style=\"word-wrap: break-word; width: 150.0; height: 150.0\"\u003e\n        \u003ca href=https://github.com/rcjsuen\u003e\n            \u003cimg src=https://avatars.githubusercontent.com/u/15629116?v=4 width=\"100;\"  alt=Remy Suen/\u003e\n            \u003cbr /\u003e\n            \u003csub style=\"font-size:14px\"\u003e\u003cb\u003eRemy Suen\u003c/b\u003e\u003c/sub\u003e\n        \u003c/a\u003e\n    \u003c/td\u003e\n    \u003ctd align=\"center\" style=\"word-wrap: break-word; width: 150.0; height: 150.0\"\u003e\n        \u003ca href=https://github.com/esomething\u003e\n            \u003cimg src=https://avatars.githubusercontent.com/u/64032?v=4 width=\"100;\"  alt=esomething/\u003e\n            \u003cbr /\u003e\n            \u003csub style=\"font-size:14px\"\u003e\u003cb\u003eesomething\u003c/b\u003e\u003c/sub\u003e\n        \u003c/a\u003e\n    \u003c/td\u003e\n\u003c/tr\u003e\n\u003c/table\u003e\n","funding_links":["https://github.com/sponsors/softcreatr","https://ecologi.com/softcreatr?r=61212ab3fc69b8eb8a2014f4"],"categories":["PHP"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FSoftCreatR%2FJSONPath","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FSoftCreatR%2FJSONPath","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FSoftCreatR%2FJSONPath/lists"}