【问题标题】:I need to return value of json expression我需要返回 json 表达式的值
【发布时间】:2020-12-12 12:32:05
【问题描述】:

我的表情是

 {
    "author": "%{\"id\" => \"f63b6f8a-4e3e-4884-8ce8-21a7885da7a7\", \"name\" => \"Bye\", \"type\" => \"AUTOMATOR\"}"
  }

上面的快递怎么退回AUTOMATOR?

我正在使用JSON_EXTRACT(author,"$.type")。 Tt 没有返回任何东西

【问题讨论】:

    标签: json json-extract


    【解决方案1】:

    您的 json 似乎无效。

    正确的 json 将是:

     { "author": {"id" :"f63b6f8a-4e3e-4884-8ce8-21a7885da7a7", "name": "Bye", "type" : "AUTOMATOR"} }
    

    您可以在线验证 JSON,例如:https://jsonformatter.curiousconcept.com/#

    【讨论】:

    • 如何获取TYPE的值?
    • 您能帮我在您共享的正确 json 中返回“type”的值吗?我应该使用什么表达方式?
    • SELECT JSON_EXTRACT('{ "author": {"id" :"f63b6f8a-4e3e-4884-8ce8-21a7885da7a7", "name": "Bye", "type" : "AUTOMATOR"} }', '$.author.type');
    • 我已经检查了来自jsonformatter.curiousconcept.com/# 的 JSON 格式似乎是正确的。您共享的解决方案适用于您共享的表达,但不适用于原始表达。
    • 字符串 { "author": "%{\"id\" => \"f63b6f8a-4e3e-4884-8ce8-21a7885da7a7\", \"name\" => \"Bye\ ", \"type\" => \"AUTOMATOR\"}" } 是 json 但作者的值是唯一的字符串,不是有效的 json
    猜你喜欢
    • 2021-06-09
    • 1970-01-01
    • 2021-12-13
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多