From the course: Advanced Redis

Unlock this course with a free trial

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

Working with JSON objects

Working with JSON objects - Redis Tutorial

From the course: Advanced Redis

Working with JSON objects

In this demo, we'll see how we can use the RedisJSON module part of a Redis Stack to work with JSON data. Here I am with the Redis command line client open and I'm going to use the JSON.SET command to set the value of a key. The value node is in the JSON format. The key here is user_001. Next, we have the path where we want this value to be set. The path here is just a $ which stands for the root path. That is the default for new keys. We'll explore paths in more detail later. And then we have the JSON structure. The JSON structure contains ID, name, location and whether a user is active. The user_001 key is now assigned a JSON value. We can use the JSON.TYPE command to check the value of the user_001 key and you can see that the value is of type object. This object here refers to a JSON object, that is, the value type for this key. You can check the types of the individual keys in the JSON object as well. Here I want to know the key for the ID within my JSON object and I specify the…

Contents