MonkeyBonkey
MonkeyBonkey

Reputation: 47881

redis node library json serialization for list values

I'm trying to create an activity feed list in redis using the redis-node library and had a json serialization question.

If I lpush a value into a key, the values get stored as escaped json, and when I retrieve with lrange, I get a list of escaped json back.

Should I simply iterate over the list items and JSON.parse(item) each, or is there a better more efficient method? Specifically, is there a configuration I can use to avoid the overhead of escaping and unescaping the json values?

Upvotes: 3

Views: 2558

Answers (1)

fent
fent

Reputation: 18205

Use JSON.strinfigy(object) when storing your value and use JSON.parse(value) when retrieving it.

Upvotes: 2

Related Questions