Handing Special JSON characters in REDIS using python

428 views Asked by At

I am trying to write and retrive a JSON with Special characters to REDIS but the special characters are getting converted

The special character Mój is getting converted to Mój and Můj is converted to Můj

from rejson import Client, Path
import json


rj = Client(host='localhost', port=6360, decode_responses=True)

app_details2 = {
  "applist": [
    {
      "appname": "Mój",
      "country": "PL"
    },
    {
      "appname": "Můj",
      "country": "CZ"
    }   
  ],
  "lasttimestamp": "2021-01-03 12:58:26",
  "loadtype":"F"
}

rj.jsonset('app_details', Path.rootPath(),app_details)
valo = rj.jsonget('app_details',Path('.applist'))
print(type(valo[0]))
print(valo)

for i in valo:
    app = i["appname"]
    country = i["country"]
    print(app)
   
1

There are 1 answers

0
Debashish Das On

The issue was resolved by adding a extra parameter to the JSONGET

valo = rj.jsonget('app_details',Path('.applist'),no_escape=True)

This solved the problem and data is getting fetched properly