Search code examples
jsonredisredisjson

ReJson - Retrieve all values from matches of 2nd layer of keys


I am trying to get all values whose 2nd level key is same. Does ReJson Support this functionality? For example:

JSON.SET myKey . '{"book1": {"author":"xyz", "price":100}, "book2": {"author":"abc", "price":200}}'

JSON.GET myKey .book1.author => "\"xyz\""

JSON.GET myKey .book2.author => "\"abc\""

Trying to fetch all author's values

JSON.GET myKey ..author

Getting the following error:

(error) ERR Search path error at offset 2: an identifier can only begin with a letter, a dollar sign or an underscore - use bracket notation for anything else`

JSON.OBJKEYS myKey . => 1) "book1" 2) "book2"

The doc says it does support JSON PATH.

Links:https://oss.redislabs.com/rejson/ https://goessner.net/articles/JsonPath/


Solution

  • No, ReJSON does not provide that functionality yet.

    The docs say:

    ReJSON's syntax is a subset of common best practices and resembles JSONPath