From the course: Advanced Redis

Unlock this course with a free trial

Join today to access over 25,300 courses taught by industry experts.

Performing operations on JSON objects

Performing operations on JSON objects - Redis Tutorial

From the course: Advanced Redis

Performing operations on JSON objects

After exploring a re operations, let's explore some operations you can perform on JSON objects. I use JSON .SET to set a new user corresponding to the key user: Sheila. The JSON object associated with this key contains a number of different attributes for Sheila, such as ID, name, location, department and so on. We've already seen how we can use the Redis serialization protocol to view a particular object, and here are the attributes for the Sheila user. Observe that this JSON object has five top level attributes, ID, name, location, department and mail. Now you can get the number of fields in a JSON object using JSON.OBJLEN. Notice that the result here is five. You can also get the number of attributes for a nested object using JSON.OBJLEN Here I want to know how many nested attributes are present for the mail top level attribute for our Sheila object. And the result here is two. Every JSON object comprises of attributes and corresponding values or keys and values. You can use…

Contents