2

If I insert the following object using ReJSON:

JSON.SET testing . '{"person":{"name":"John","surname":"Doe"}}'

Is there a way to "append" a nested structure? I would like to add "address.name" for an example to get the following JSON:

{
  "person": {
    "name": "John",
    "surname": "Doe"
  },
  "address": {
    "name": "Imaginary Street"
  }
}

I was trying to use JSON.SET testing .address.name '"Imaginary Street 7"' but this results in (error) ERR missing key at non-terminal path level.

The docs read:

A key (with its respective value) is added to a JSON Object (in a Redis ReJSON data type key) if and only if it is the last child in the path.

Is "address.name" not the last child in the path? What am I doing wrong?

1 Answer 1

4

Since you're adding a dictionary ('address'), the way to go about this is:

JSON.SET testing .address '{"name": "Imaginary Street"}'

Alternatively, if you do just:

JSON.SET testing .address '{}'

you'll be able to use the command from your question without any errors.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.