【问题标题】:Is there any way to escape dot in path Json1 Sqlite有什么办法可以在路径 Json1 Sqlite 中转义点
【发布时间】:2018-05-10 20:18:18
【问题描述】:

似乎如果我有密钥test1.test2,则无法转义此点以按原样使用此密钥。

表达式:

sqlite> update collections set json_nodes = (select json_set(json(collections.js
on_nodes), '$.test.test1', json('123')) from collections);

会导致

{"test":{"test1":123}}

【问题讨论】:

  • 欢迎来到 Stack Overflow,为什么会有这个星座?
  • 你试过反斜杠吗?
  • update collections set json_nodes = (select json_set(json(collections.js on_nodes), '$."test.test1"', json('123')) from collections);'$.test.test1]'

标签: sqlite sqlite-json1


【解决方案1】:

对于查找,您可以将包含点的键名括在双引号中。但是,如果您的密钥名称包含双引号,我认为您不走运,除非您将源代码修改为 JSON1 扩展。

双引号转义似乎没有文档记录,但您可以从 the source code to the JSON1 extension 的函数 jsonLookupStep 中看到它的工作方式。

例子:

SELECT json_extract(json_data, '$."Issuer.LongCompanyName"')
FROM instruments_table

【讨论】:

    猜你喜欢
    • 2016-06-27
    • 1970-01-01
    • 2015-08-04
    • 2023-01-24
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2010-11-15
    • 2022-11-24
    相关资源
    最近更新 更多