【问题标题】:Redis cjson: Is there a way to manipulate JSON without decoding it completely?Redis cjson:有没有办法在不完全解码的情况下操作 JSON?
【发布时间】:2018-05-15 21:29:50
【问题描述】:

鉴于下面的例子,有没有办法在不解码的情况下将值从“bar”更改为“blah”?

redis 127.0.0.1:6379> eval 'return cjson.encode({["foo"]= "bar"})' 0
"{\"foo\":\"bar\"}"

redis 127.0.0.1:6379> eval 'return cjson.decode(ARGV[1])["foo"]' 0 "{\"foo\":\"bar\"}"
"bar"

参考例如:https://redis.io/commands/eval

【问题讨论】:

  • ReJSON 模块可能会有所帮助
  • @for_stack 无法更改,因为 Redis 带有 cjson。而且我无法加载另一个模块。

标签: lua redis cjson


【解决方案1】:

不行,您必须经历一个完整的解码和编码周期。这正是http://rejson.io 试图解决的“痛点”之一。请参阅http://rejson.io/performance/#comparison-vs-server-side-lua-scripting 了解更多信息。

免责声明:这里是 ReJSON 的作者。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2021-08-10
    • 1970-01-01
    • 2021-12-19
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-03-17
    相关资源
    最近更新 更多