Fetch specific keys from array of object in redisJson

646 Views Asked by At

I want to fetch starting 10 records with specific keys in Redis JSON - {uuid,content} using JSON.GET.

I can fetch the 10 records and only one key using this command - JSON.GET blogs $.[0:10].uuid .

How do i fetch other keys?

Data -

[
    {
         "uuid" : "111111",
         "content" : "xxx",
         "somekey": "sss"
    },
    {
         "uuid" : "1222",
         "content" : "xxx",
         "somekey": "sss"
    }
]

Expected Data -

[
    {
         "uuid" : "111111",
         "content" : "xxx"
    },
    {
         "uuid" : "1222",
         "content" : "xxx",
    }
]
1

There are 1 best solutions below

2
Lior Kogan On

How about this:

JSON.SET blogs $ '[{"uuid" : "111111", "content" : "xxx","somekey": "sss"},{"uuid" : "1222","content" : "xxx","somekey": "sss"}]'
JSON.GET blogs '$[0:10]["uuid", "content"]'
["111111","xxx","1222","xxx"]