Closed
Description
I'm trying to store a json with some chinese character in redis with rejson like this:
127.0.0.1:6379> JSON.SET test . '{"key":"测试"}'
OK
127.0.0.1:6379> JSON.GET test .key
"\u00e6\u00b5\u008b\u00e8\u00af\u0095"
127.0.0.1:6379> SET test2 "测试"
OK
127.0.0.1:6379> GET test2
测试
127.0.0.1:6379>
As you can see the value "测试" convert to "\u00e6\u00b5\u008b\u00e8\u00af\u0095" when using JSON.GET... It looks like rejson didn't support unicode yet...
Activity
dvirsky commentedon Sep 15, 2017
@wgjak47 the data should be encoded as UTF-8 IIRC.
wgjak47 commentedon Sep 16, 2017
It looks like the data is encoded with 'ISO-8859' not utf-8...
And I have tried to encoded the data with utf-8, but it doesn't work:
Any example?
thienit5 commentedon Sep 18, 2017
I have the same problem, can you show me how to decode?
dvirsky commentedon Sep 19, 2017
@wgjak47 @thienit5
wgjak47 commentedon Oct 2, 2017
look like it doesn't work
wgjak47 commentedon Oct 6, 2017
I found the reson, In json_object.c/_JSONSerialize_StringValue(Node *n, void *ctx), for any char not in ascii, it just response in hex:
mnunberg commentedon Oct 19, 2017
I've just fixed this issue in master. Can you tell me if this works for you?
wgjak47 commentedon Oct 20, 2017
It works! Thank you. @mnunberg
nelsonlarocca commentedon Nov 14, 2019
Guys, here asking for a recommendation.
I've found that nodejs redis rejson clients ("redis-rejson" and "iorejson") handling the REJSON extension always retrieve the json data using escaped unicode and since they are wrapping the redis and ioredis modules, there's no way to include the arg NOESCAPE as an option
Do you know about any nodejs module or any trick that could handle that without much overhead ?
Thanks !
xtianus79 commentedon Dec 24, 2019
@mnunberg thank you jesus... This was a memory leak until this fix was put into place. Why such a drastic difference for something such as NOESCAPE?
here is what I did using IOREDIS
xtianus79 commentedon Dec 24, 2019
Just to show you guys how this was causing a memory leak... I was using a read for an internal state object and that would be used as a write down the line. here was the result. YIKES!!!
so needless to say, thanks for the fix.
ghost commentedon Apr 13, 2020
Here is the JAVA(JReJSON) solution:
JReJSON redisClient = new JReJSON(redisHost, redisPort);
redisClient.get(key, new Path("NOESCAPE"));
gkorland commentedon Dec 19, 2021
Should work now see: