[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"project-4138":3},{"id":4,"name":5,"fullName":6,"owner":7,"repo":5,"description":8,"homepage":9,"htmlUrl":10,"language":11,"languages":10,"totalLinesOfCode":10,"stars":12,"forks":13,"watchers":14,"openIssues":15,"contributorsCount":16,"subscribersCount":16,"size":16,"stars1d":16,"stars7d":17,"stars30d":18,"stars90d":16,"forks30d":16,"starsTrendScore":17,"compositeScore":19,"rankGlobal":10,"rankLanguage":10,"license":20,"archived":21,"fork":21,"defaultBranch":22,"hasWiki":21,"hasPages":21,"topics":23,"createdAt":10,"pushedAt":10,"updatedAt":24,"readmeContent":25,"aiSummary":26,"trendingCount":16,"starSnapshotCount":16,"syncStatus":27,"lastSyncTime":28,"discoverSource":29},4138,"JsonPath","json-path\u002FJsonPath","json-path","Java JsonPath implementation","",null,"Java",9414,1712,282,348,0,1,10,67.2,"Apache License 2.0",false,"master",[],"2026-06-12 04:00:21","Jayway JsonPath\n=====================\n\n**A Java DSL for reading JSON documents.**\n\n[![Build Status](https:\u002F\u002Ftravis-ci.org\u002Fjson-path\u002FJsonPath.svg?branch=master)](https:\u002F\u002Ftravis-ci.org\u002Fjson-path\u002FJsonPath)\n[![Maven Central](https:\u002F\u002Fmaven-badges.herokuapp.com\u002Fmaven-central\u002Fcom.jayway.jsonpath\u002Fjson-path\u002Fbadge.svg)](https:\u002F\u002Fmaven-badges.herokuapp.com\u002Fmaven-central\u002Fcom.jayway.jsonpath\u002Fjson-path)\n[![Javadoc](https:\u002F\u002Fwww.javadoc.io\u002Fbadge\u002Fcom.jayway.jsonpath\u002Fjson-path.svg)](http:\u002F\u002Fwww.javadoc.io\u002Fdoc\u002Fcom.jayway.jsonpath\u002Fjson-path)\n\nJayway JsonPath is a Java port of [Stefan Goessner JsonPath implementation](http:\u002F\u002Fgoessner.net\u002Farticles\u002FJsonPath\u002F).\n\nGetting Started\n---------------\n\nJsonPath is available at the Central Maven Repository. Maven users add this to your POM.\n\n> [!NOTE]  \n> Version 3.0.0 Uses Java 17 baseline to support Jackson 3\n\n```xml\n\n\u003Cdependency>\n    \u003CgroupId>com.jayway.jsonpath\u003C\u002FgroupId>\n    \u003CartifactId>json-path\u003C\u002FartifactId>\n    \u003Cversion>3.0.0\u003C\u002Fversion>\n\u003C\u002Fdependency>\n```\n\nIf you need help ask questions at [Stack Overflow](http:\u002F\u002Fstackoverflow.com\u002Fquestions\u002Ftagged\u002Fjsonpath). Tag the\nquestion 'jsonpath' and 'java'.\n\nJsonPath expressions always refer to a JSON structure in the same way as XPath expression are used in combination\nwith an XML document. The \"root member object\" in JsonPath is always referred to as `$` regardless if it is an\nobject or array.\n\nJsonPath expressions can use the dot–notation\n\n`$.store.book[0].title`\n\nor the bracket–notation\n\n`$['store']['book'][0]['title']`\n\nOperators\n---------\n\n| Operator                  | Description                                                     |\n|:--------------------------|:----------------------------------------------------------------|\n| `$`                       | The root element to query. This starts all path expressions.    |\n| `@`                       | The current node being processed by a filter predicate.         |\n| `*`                       | Wildcard. Available anywhere a name or numeric are required.    |\n| `..`                      | Deep scan. Available anywhere a name is required.               |\n| `.\u003Cname>`                 | Dot-notated child                                               |\n| `['\u003Cname>' (, '\u003Cname>')]` | Bracket-notated child or children                               |\n| `[\u003Cnumber> (, \u003Cnumber>)]` | Array index or indexes                                          |\n| `[start:end]`             | Array slice operator                                            |\n| `[?(\u003Cexpression>)]`       | Filter expression. Expression must evaluate to a boolean value. |\n\nFunctions\n---------\n\nFunctions can be invoked at the tail end of a path - the input to a function is the output of the path expression.\nThe function output is dictated by the function itself.\n\n| Function    | Description                                                                          | Output type          |\n|:------------|:-------------------------------------------------------------------------------------|:---------------------|\n| `min()`     | Provides the min value of an array of numbers                                        | Double               |\n| `max()`     | Provides the max value of an array of numbers                                        | Double               |\n| `avg()`     | Provides the average value of an array of numbers                                    | Double               | \n| `stddev()`  | Provides the standard deviation value of an array of numbers                         | Double               | \n| `length()`  | Provides the length of an array                                                      | Integer              |\n| `sum()`     | Provides the sum value of an array of numbers                                        | Double               |\n| `keys()`    | Provides the property keys (An alternative for terminal tilde `~`)                   | `Set\u003CE>`             |\n| `concat(X)` | Provides a concatinated version of the path output with a new item                   | like input           |\n| `append(X)` | add an item to the json path output array                                            | like input           |\n| `first()`   | Provides the first item of an array                                                  | Depends on the array |\n| `last()`    | Provides the last item of an array                                                   | Depends on the array |\n| `index(X)`  | Provides the item of an array of index: X, if the X is negative, take from backwards | Depends on the array |\n\nFilter Operators\n-----------------\n\nFilters are logical expressions used to filter arrays. A typical filter would be `[?(@.age > 18)]` where `@` represents\nthe current item being processed. More complex filters can be created with logical operators `&&` and `||`. String\nliterals must be enclosed by single or double quotes (`[?(@.color == 'blue')]` or `[?(@.color == \"blue\")]`).\n\n| Operator   | Description                                                        |\n|:-----------|:-------------------------------------------------------------------|\n| `==`       | left is equal to right (note that 1 is not equal to '1')           |\n| `!=`       | left is not equal to right                                         |\n| `\u003C`        | left is less than right                                            |\n| `\u003C=`       | left is less or equal to right                                     |\n| `>`        | left is greater than right                                         |\n| `>=`       | left is greater than or equal to right                             |\n| `=~`       | left matches regular expression  [?(@.name =~ \u002Ffoo.*?\u002Fi)]          |\n| `in`       | left exists in right [?(@.size in ['S', 'M'])]                     |\n| `nin`      | left does not exists in right                                      |\n| `subsetof` | left is a subset of right [?(@.sizes subsetof ['S', 'M', 'L'])]    |\n| `anyof`    | left has an intersection with right [?(@.sizes anyof ['M', 'L'])]  |\n| `noneof`   | left has no intersection with right [?(@.sizes noneof ['M', 'L'])] |\n| `size`     | size of left (array or string) should match right                  |\n| `empty`    | left (array or string) should be empty                             |\n\nPath Examples\n-------------\n\nGiven the json\n\n```javascript\n{\n    \"store\": {\n        \"book\": [\n            {\n                \"category\": \"reference\",\n                \"author\": \"Nigel Rees\",\n                \"title\": \"Sayings of the Century\",\n                \"price\": 8.95\n            },\n            {\n                \"category\": \"fiction\",\n                \"author\": \"Evelyn Waugh\",\n                \"title\": \"Sword of Honour\",\n                \"price\": 12.99\n            },\n            {\n                \"category\": \"fiction\",\n                \"author\": \"Herman Melville\",\n                \"title\": \"Moby Dick\",\n                \"isbn\": \"0-553-21311-3\",\n                \"price\": 8.99\n            },\n            {\n                \"category\": \"fiction\",\n                \"author\": \"J. R. R. Tolkien\",\n                \"title\": \"The Lord of the Rings\",\n                \"isbn\": \"0-395-19395-8\",\n                \"price\": 22.99\n            }\n        ],\n        \"bicycle\": {\n            \"color\": \"red\",\n            \"price\": 19.95\n        }\n    },\n    \"expensive\": 10\n}\n```\n\n| JsonPath                                | Result                                                       |\n|:----------------------------------------|:-------------------------------------------------------------|\n| `$.store.book[*].author`                | The authors of all books                                     |\n| `$..author`                             | All authors                                                  |\n| `$.store.*`                             | All things, both books and bicycles                          |\n| `$.store..price`                        | The price of everything                                      |\n| `$..book[2]`                            | The third book                                               |\n| `$..book[-2]`                           | The second to last book                                      |\n| `$..book[0,1]`                          | The first two books                                          |\n| `$..book[:2]`                           | All books from index 0 (inclusive) until index 2 (exclusive) |\n| `$..book[1:2]`                          | All books from index 1 (inclusive) until index 2 (exclusive) |\n| `$..book[-2:]`                          | Last two books                                               |\n| `$..book[2:]`                           | All books from index 2 (inclusive) to last                   |\n| `$..book[?(@.isbn)]`                    | All books with an ISBN number                                |\n| `$.store.book[?(@.price \u003C 10)]`         | All books in store cheaper than 10                           |\n| `$..book[?(@.price \u003C= $['expensive'])]` | All books in store that are not \"expensive\"                  |\n| `$..book[?(@.author =~ \u002F.*REES\u002Fi)]`     | All books matching regex (ignore case)                       |\n| `$..*`                                  | Give me every thing                                          \n| `$..book.length()`                      | The number of books                                          |\n\nReading a Document\n------------------\nThe simplest most straight forward way to use JsonPath is via the static read API.\n\n```java\nString json = \"...\";\n\nList\u003CString> authors = JsonPath.read(json, \"$.store.book[*].author\");\n```\n\nIf you only want to read once this is OK. In case you need to read an other path as well this is not the way\nto go since the document will be parsed every time you call JsonPath.read(...). To avoid the problem you can\nparse the json first.\n\n```java\nString json = \"...\";\nObject document = Configuration.defaultConfiguration().jsonProvider().parse(json);\n\nString author0 = JsonPath.read(document, \"$.store.book[0].author\");\nString author1 = JsonPath.read(document, \"$.store.book[1].author\");\n```\n\nJsonPath also provides a fluent API. This is also the most flexible one.\n\n```java\nString json = \"...\";\n\nReadContext ctx = JsonPath.parse(json);\n\nList\u003CString> authorsOfBooksWithISBN = ctx.read(\"$.store.book[?(@.isbn)].author\");\n\n\nList\u003CMap\u003CString, Object>> expensiveBooks = JsonPath\n        .using(configuration)\n        .parse(json)\n        .read(\"$.store.book[?(@.price > 10)]\", List.class);\n```\n\nWhat is Returned When?\n----------------------\nWhen using JsonPath in java its important to know what type you expect in your result. JsonPath will automatically\ntry to cast the result to the type expected by the invoker.\n\n```java\n\u002F\u002FWill throw an java.lang.ClassCastException    \nList\u003CString> list = JsonPath.parse(json).read(\"$.store.book[0].author\");\n\n\u002F\u002FWorks fine\nString author = JsonPath.parse(json).read(\"$.store.book[0].author\");\n```\n\nWhen evaluating a path you need to understand the concept of when a path is `definite`. A path is `indefinite` if it\ncontains:\n\n* `..` - a deep scan operator\n* `?(\u003Cexpression>)` - an expression\n* `[\u003Cnumber>, \u003Cnumber> (, \u003Cnumber>)]` - multiple array indexes\n\n`Indefinite` paths always returns a list (as represented by current JsonProvider).\n\nBy default a simple object mapper is provided by the MappingProvider SPI. This allows you to specify the return type you\nwant and the MappingProvider will\ntry to perform the mapping. In the example below mapping between `Long` and `Date` is demonstrated.\n\n```java\nString json = \"{\\\"date_as_long\\\" : 1411455611975}\";\n\nDate date = JsonPath.parse(json).read(\"$['date_as_long']\", Date.class);\n```\n\nIf you configure JsonPath to use `JacksonMappingProvider`, `Jackson3MappingProvider`, `GsonMappingProvider`,\nor `JakartaJsonProvider` you can even\nmap your JsonPath output directly into POJO's.\n\n```java\nBook book = JsonPath.parse(json).read(\"$.store.book[0]\", Book.class);\n```\n\nTo obtain full generics type information, use TypeRef.\n\n```java\nTypeRef\u003CList\u003CString>> typeRef = new TypeRef\u003CList\u003CString>>() {\n};\n\nList\u003CString> titles = JsonPath.parse(JSON_DOCUMENT).read(\"$.store.book[*].title\", typeRef);\n```\n\nPredicates\n----------\nThere are three different ways to create filter predicates in JsonPath.\n\n### Inline Predicates\n\nInline predicates are the ones defined in the path.\n\n```java\nList\u003CMap\u003CString, Object>> books = JsonPath.parse(json)\n        .read(\"$.store.book[?(@.price \u003C 10)]\");\n```\n\nYou can use `&&` and `||` to combine multiple predicates `[?(@.price \u003C 10 && @.category == 'fiction')]` ,\n`[?(@.category == 'reference' || @.price > 10)]`.\n\nYou can use `!` to negate a predicate `[?(!(@.price \u003C 10 && @.category == 'fiction'))]`.\n\n### Filter Predicates\n\nPredicates can be built using the Filter API as shown below:\n\n```java\nimport static com.jayway.jsonpath.JsonPath.parse;\nimport static com.jayway.jsonpath.Criteria.where;\nimport static com.jayway.jsonpath.Filter.filter;\n...\n        ...\n\nFilter cheapFictionFilter = filter(\n        where(\"category\").is(\"fiction\").and(\"price\").lte(10D)\n);\n\nList\u003CMap\u003CString, Object>> books =\n        parse(json).read(\"$.store.book[?]\", cheapFictionFilter);\n\n```\n\nNotice the placeholder `?` for the filter in the path. When multiple filters are provided they are applied in order\nwhere the number of placeholders must match\nthe number of provided filters. You can specify multiple predicate placeholders in one filter operation `[?, ?]`, both\npredicates must match.\n\nFilters can also be combined with 'OR' and 'AND'\n\n```java\nFilter fooOrBar = filter(\n        where(\"foo\").exists(true)).or(where(\"bar\").exists(true)\n);\n\nFilter fooAndBar = filter(\n        where(\"foo\").exists(true)).and(where(\"bar\").exists(true)\n);\n```\n\n### Roll Your Own\n\nThird option is to implement your own predicates\n\n```java \nPredicate booksWithISBN = new Predicate() {\n    @Override\n    public boolean apply(PredicateContext ctx) {\n        return ctx.item(Map.class).containsKey(\"isbn\");\n    }\n};\n\nList\u003CMap\u003CString, Object>> books =\n        reader.read(\"$.store.book[?].isbn\", List.class, booksWithISBN);\n```\n\nPath vs Value\n-------------\nIn the Goessner implementation a JsonPath can return either `Path` or `Value`. `Value` is the default and what all the\nexamples above are returning. If you rather have the path of the elements our query is hitting this can be achieved with\nan option.\n\n```java\nConfiguration conf = Configuration.builder()\n        .options(Option.AS_PATH_LIST).build();\n\nList\u003CString> pathList = using(conf).parse(json).read(\"$..author\");\n\nassertThat(pathList).\n\ncontainsExactly(\n    \"$['store']['book'][0]['author']\",\n            \"$['store']['book'][1]['author']\",\n            \"$['store']['book'][2]['author']\",\n            \"$['store']['book'][3]['author']\");\n```\n\nSet a value\n-----------\nThe library offers the possibility to set a value.\n\n```java\nString newJson = JsonPath.parse(json).set(\"$['store']['book'][0]['author']\", \"Paul\").jsonString();\n```\n\nTweaking Configuration\n----------------------\n\n### Options\n\nWhen creating your Configuration there are a few option flags that can alter the default behaviour.\n\n**DEFAULT_PATH_LEAF_TO_NULL**\n\u003Cbr\u002F>\nThis option makes JsonPath return null for missing leafs. Consider the following json\n\n```javascript\n[\n   {\n      \"name\" : \"john\",\n      \"gender\" : \"male\"\n   },\n   {\n      \"name\" : \"ben\"\n   }\n]\n```\n\n```java\nConfiguration conf = Configuration.defaultConfiguration();\n\n\u002F\u002FWorks fine\nString gender0 = JsonPath.using(conf).parse(json).read(\"$[0]['gender']\");\n\u002F\u002FPathNotFoundException thrown\nString gender1 = JsonPath.using(conf).parse(json).read(\"$[1]['gender']\");\n\nConfiguration conf2 = conf.addOptions(Option.DEFAULT_PATH_LEAF_TO_NULL);\n\n\u002F\u002FWorks fine\nString gender0 = JsonPath.using(conf2).parse(json).read(\"$[0]['gender']\");\n\u002F\u002FWorks fine (null is returned)\nString gender1 = JsonPath.using(conf2).parse(json).read(\"$[1]['gender']\");\n```\n\n**ALWAYS_RETURN_LIST**\n\u003Cbr\u002F>\nThis option configures JsonPath to return a list even when the path is `definite`.\n\n```java\nConfiguration conf = Configuration.defaultConfiguration();\n\n\u002F\u002FClassCastException thrown\nList\u003CString> genders0 = JsonPath.using(conf).parse(json).read(\"$[0]['gender']\");\n\nConfiguration conf2 = conf.addOptions(Option.ALWAYS_RETURN_LIST);\n\n\u002F\u002FWorks fine\nList\u003CString> genders0 = JsonPath.using(conf2).parse(json).read(\"$[0]['gender']\");\n``` \n\n**SUPPRESS_EXCEPTIONS**\n\u003Cbr\u002F>\nThis option makes sure no exceptions are propagated from path evaluation. It follows these simple rules:\n\n* If option `ALWAYS_RETURN_LIST` is present an empty list will be returned\n* If option `ALWAYS_RETURN_LIST` is **NOT** present null returned\n\n**REQUIRE_PROPERTIES**\n\u003C\u002Fbr>\nThis option configures JsonPath to require properties defined in path when an `indefinite` path is evaluated.\n\n```java\nConfiguration conf = Configuration.defaultConfiguration();\n\n\u002F\u002FWorks fine\nList\u003CString> genders = JsonPath.using(conf).parse(json).read(\"$[*]['gender']\");\n\nConfiguration conf2 = conf.addOptions(Option.REQUIRE_PROPERTIES);\n\n\u002F\u002FPathNotFoundException thrown\nList\u003CString> genders = JsonPath.using(conf2).parse(json).read(\"$[*]['gender']\");\n```\n\n### JsonProvider SPI\n\nJsonPath is shipped with five different JsonProviders:\n\n* [JsonSmartJsonProvider](https:\u002F\u002Fgithub.com\u002Fnetplex\u002Fjson-smart-v2) (default)\n* [JacksonJsonProvider](https:\u002F\u002Fgithub.com\u002FFasterXML\u002Fjackson)\n* [JacksonJsonNodeJsonProvider](https:\u002F\u002Fgithub.com\u002FFasterXML\u002Fjackson)\n* [JacksonJson3Provider](https:\u002F\u002Fgithub.com\u002FFasterXML\u002Fjackson)\n* [JacksonJson3NodeJsonProvider](https:\u002F\u002Fgithub.com\u002FFasterXML\u002Fjackson)\n* [GsonJsonProvider](https:\u002F\u002Fcode.google.com\u002Fp\u002Fgoogle-gson\u002F)\n* [JsonOrgJsonProvider](https:\u002F\u002Fgithub.com\u002Fstleary\u002FJSON-java)\n* [JakartaJsonProvider](https:\u002F\u002Fjavaee.github.io\u002Fjsonp\u002F)\n\nChanging the configuration defaults as demonstrated should only be done when your application is being initialized.\nChanges during runtime is strongly discouraged, especially in multi threaded applications.\n\n```java\nConfiguration.setDefaults(new Configuration.Defaults() {\n\n    private final JsonProvider jsonProvider = new JacksonJsonProvider();\n    private final MappingProvider mappingProvider = new JacksonMappingProvider();\n\n    @Override\n    public JsonProvider jsonProvider () {\n        return jsonProvider;\n    }\n\n    @Override\n    public MappingProvider mappingProvider () {\n        return mappingProvider;\n    }\n\n    @Override\n    public Set\u003COption> options () {\n        return EnumSet.noneOf(Option.class);\n    }\n});\n```\n\nNote that the JacksonJsonProvider requires `com.fasterxml.jackson.core:jackson-databind:2.20.1`, the\nJackson3JsonProvider requires `tools.jackson.core:jackson-databind:3.0.3` and the GsonJsonProvider\nrequires `com.google.code.gson:gson:2.3.1` on your classpath.\n\nBoth of Jakarta EE 9 [JSON-P (JSR-342)](https:\u002F\u002Fjavaee.github.io\u002Fjsonp\u002F) and [JSON-B (JSR-367)](http:\u002F\u002Fjson-b.net\u002F)\nproviders expect at least Java 8 and require compatible JSON API implementations (such\nas [Eclipse Glassfish](https:\u002F\u002Fprojects.eclipse.org\u002Fprojects\u002Fee4j.jsonp)\nand [Eclipse Yasson](https:\u002F\u002Fprojects.eclipse.org\u002Fprojects\u002Fee4j.yasson)) on application runtime classpath; such\nimplementations may also be provided by Java EE application container. Please also note that Apache Johnzon is not\nclasspath-compatible with Jakarta EE 9 specification yet, and if JSON-B mapping provider is chosen then JSON-P provider\nmust be configured and used, too.\n\nOne peculiarity of Jakarta EE 9 specifications for JSON processing and databinding (mapping) is immutability of Json\narrays and objects as soon as they are fully parsed or written to. To respect the API specification, but allow JsonPath\nto modify Json documents through add, set\u002Fput, replace, and delete operations, `JakartaJsonProvider` has to be\ninitiliazed with optional `true` argument:\n\n* `JsonProvider jsonProvider = new JakartaJsonProvider(true)` (enable mutable Json arrays and objects)\n* `JsonProvider jsonProvider = new JakartaJsonProvider()` (default, strict JSON-P API compliance)\n\nAll lookup and read operations with JsonPath are supported regardless of initilization mode. Default mode also needs\nless memory and is more performant.\n\n### Cache SPI\n\nIn JsonPath 2.1.0 a new Cache SPI was introduced. This allows API consumers to configure path caching in a way that\nsuits their needs. The cache must be configured before it is accesses for the first time or a JsonPathException is\nthrown. JsonPath ships with two cache implementations\n\n* `com.jayway.jsonpath.spi.cache.LRUCache` (default, thread safe)\n* `com.jayway.jsonpath.spi.cache.NOOPCache` (no cache)\n\nIf you want to implement your own cache the API is simple.\n\n```java\nCacheProvider.setCache(new Cache() {\n    \u002F\u002FNot thread safe simple cache\n    private Map\u003CString, JsonPath> map = new HashMap\u003CString, JsonPath>();\n\n    @Override\n    public JsonPath get (String key){\n        return map.get(key);\n    }\n\n    @Override\n    public void put (String key, JsonPath jsonPath){\n        map.put(key, jsonPath);\n    }\n});\n```\n\n[![Analytics](https:\u002F\u002Fga-beacon.appspot.com\u002FUA-54945131-1\u002Fjsonpath\u002Findex)](https:\u002F\u002Fgithub.com\u002Figrigorik\u002Fga-beacon)\n","Jayway JsonPath 是一个用于读取 JSON 文档的 Java 域特定语言。它支持使用类似于 XPath 的表达式来查询和提取 JSON 数据，提供了丰富的操作符和函数以满足复杂的解析需求，如通过点记法或括号记法访问嵌套对象、数组索引以及应用过滤条件等。该项目基于 Apache License 2.0 开源协议发布，适合需要在Java环境中高效处理JSON数据的应用场景，比如Web服务开发、数据转换工具构建等领域。",2,"2026-06-11 02:58:38","top_language"]