Skip to content

Commit 2455b82

Browse files
author
Kyle Banker
committed
minor: edits
1 parent e4dbdc6 commit 2455b82

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

docs/howtos/redisjson/using-python/index-usingpython.mdx

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ sidebar_label: RedisJSON and Python
55
slug: /howtos/redisjson/using-python
66
---
77

8-
[RedisJSON](https://oss.redis.com/redisjson/) is a source-available Redis module that lets you store, manipulate, and query JSON documents in Redis. The standard Redis Python client (v4.0 or greater) supports all of the feature of RedisJSON, and in this tutorial, we'll see how to use them.
8+
[RedisJSON](https://oss.redis.com/redisjson/) is a source-available Redis module that lets you store, manipulate, and query JSON documents in Redis. The standard Redis Python client (v4.0 or greater) supports all of the features of RedisJSON, and in this tutorial, we'll see how to get started with them.
99

1010
## Getting started with RedisJSON
1111

@@ -33,7 +33,7 @@ Ensure that you're running RedisJSON v2.0 or greater (here indicated as `20004`)
3333

3434
You'll need `redis-py` version 4.0 or later. If you're using `pipenv`, you can install the client library like so:
3535

36-
```
36+
```bash
3737
pipenv install redis
3838
```
3939

@@ -51,8 +51,8 @@ Let's consider a simple JSON document structure representing a user:
5151
```
5252
{
5353
"name": "Jane",
54-
"age": 25,
55-
"location: "USA"
54+
"age": 33,
55+
"location: "Chawton"
5656
}
5757
```
5858

@@ -80,28 +80,28 @@ In the code above, we first connect to Redis and store a reference to the connec
8080

8181
Next, we create a Python dictionary to represent a person object.
8282

83-
And finally, we store the object in Redis using the `json().set()` method. The first argument, `person:1` is the name of the key that will store the JSON. The second argument is a JSON path. We use `Path.rootPath()`, as this is a new object. Finally, we pass in the Python dictionary, which will be serialized to JSON.
83+
And finally, we store the object in Redis using the `json().set()` method. The first argument, `person:1` is the name of the key that will reference the JSON. The second argument is a JSON path. We use `Path.rootPath()`, as this is a new object. Finally, we pass in the Python dictionary, which will be serialized to JSON.
8484

85-
To retrieve the JSON object, we run `json().get()`, passing the key. The result is the Python dictionary we passed in.
85+
To retrieve the JSON object, we run `json().get()`, passing in the key. The result is a Python dictionary representing the JSON object stored in Redis.
8686

8787
### Run the code
8888

89-
If you copy the code above in a file called `main.py`, you can run the code like so:
89+
If you copy the code above into a file called `main.py`, you can run the code like so:
9090

9191
```bash
9292
$ pipenv python run main.py
93-
93+
```
9494

9595
## Verify that the JSON document has been added to Redis
9696

97-
Start `redis-cli` to connect to your Redis instance. The run the following command:
97+
Start `redis-cli` to connect to your Redis instance. Then run the following command:
9898

9999
```bash
100100
localhost:6379> json.get person:1
101101
"{\"name\":\"Jane\",\"Age\":33,\"Location\":\"Chawton\"}"
102102
```
103103

104-
## Fetching the specific fields within a JSON document
104+
## Fetching specific fields from a JSON document
105105

106106
You can use RedisJSON to fetch specific fields from a document by specifying a path. For example, here's how to return only the `name` field:
107107

0 commit comments

Comments
 (0)