2

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/

Guy Korland
  • 9,139
  • 14
  • 59
  • 106
abhijit gupta
  • 161
  • 1
  • 12

2 Answers2

1

No, ReJSON does not provide that functionality yet.

The docs say:

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

Itamar Haber
  • 47,336
  • 7
  • 91
  • 117
-2

try:

json.mget myKey $..author

https://oss.redis.com/redisjson/commands/#jsonmget

Stephen Rauch
  • 47,830
  • 31
  • 106
  • 135
li chen
  • 1
  • 1
  • 127.0.0.1:6379> JSON.SET myKey . '{"book1": {"author":"xyz", "price":100}, "book2": {"author":"abc", "price":200}}' OK 127.0.0.1:6379> json.mget myKey $..author 1) "[\"xyz\",\"abc\"]" – li chen Jan 09 '22 at 04:20