1

I am using redisJson and I have the following json structure:

foobar_1" : {
   "some" : "value",
   "number" : 28148,
   "timestamp" : 1659013007,
    "inner" : {
           "someinner" : "value",
           "innertimestamp" : 1659013007}
},

"foobar_2" : {
   "some ": "value",
   "number" : 59851,
   "timestamp" : 1659013007,
    "inner" : {
              "someinner" : "value",
              "innertimestamp" : 1659013007
}

now I want to add a value to all 'inner' so it looks like this:

foobar_1" : {
   "some" : "value",
   "number" : 28148,
   "timestamp" : 1659013007,
    "inner" : {
           "someinner" : "value",
           "innertimestamp" : 1659013007,
           "newvalue" : "abc"                 <---------------
          }
},

"foobar_2" : {
   "some ": "value",
   "number" : 59851,
   "timestamp" : 1659013007,
    "inner" : {
              "someinner" : "value",
              "innertimestamp" : 1659013007,
              "newvalue" : "abc"                 <---------------
      }
}

I thought it would just go like this:

redis> JSON.SET mykey $..inner.newvalue 'abc'

But this gives me: RedisException: Err: wrong static path

jsx380
  • 43
  • 3
  • 2
    Could be an issue with how RedisJSON is parsing JSON paths, see this issue: https://github.com/RedisJSON/RedisJSON/issues/788 in RedisJSON – slorello Jul 28 '22 at 18:20
  • Thanks for posting the issue on Github. So you think it's a bug? That surprises me... I thought that would be a frequently used function of redisJson – jsx380 Jul 28 '22 at 19:10
  • Btw: *redis> JSON.SET mykey $.foobar_2.inner.newvalue 'abc'* works - i can set a single value. So the problem is the .. operator – jsx380 Jul 28 '22 at 19:12
  • Yeah, so RedisJSON is supposed to create a new node for you if the parent exists, according to the docs - so this only seems to be an issue with creating new nodes from recursive descent paths. – slorello Jul 28 '22 at 19:34

0 Answers0