'How do you update a value with a path in complex object in Redis/ReJson on Kubernetes?

I am trying to update a complex object via a path value which it appear ReJson can do. I have used it as a Cache just fine, I want to use it as a json collection store for real time data (similar to mongodb).

for example: { "name": "Michael \u0027Mike D\u0027 Diamond", "employeeID": "E#101", "role": "Cleaner", "location": { "longitude": -2.552079, "lattitude": 51.501335 }, "numberOfAssignedJobs": 5 }

For example I want to update location.lattitude without taking the whole object and dealing with read/write sync issues.

However I am struggling with the API/How it is used in kubernetes. If anyone has any example code or tips and tricks, anything is much appreciated.

Thanks, Matt



Solution 1:[1]

You can do this with the JSON.GET command and JSON path syntax (docs here)

First, save the document in Redis at key "jsondoc":

127.0.0.1:6379> json.set jsondoc $ '{ "name": "Michael \u0027Mike D\u0027 Diamond", "employeeID": "E#101", "role": "Cleaner", "location": { "longitude": -2.552079, "latitude": 51.501335 }, "numberOfAssignedJobs": 5 }'

Atomically update path location.latitude to some other value:

127.0.0.1:6379> json.set jsondoc $.location.latitude 52.014
OK

Retrieve just location.latitude:

127.0.0.1:6379> json.get jsondoc $.location.latitude
"52.014"

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Simon Prickett