【问题标题】:Hive and get_json_object strange behaviorHive 和 get_json_object 奇怪的行为
【发布时间】:2011-10-05 10:57:10
【问题描述】:

我正在运行 hive 查询,使用 get_json_object 从 HDFS 中的文件中读取 json 字符串。 我遇到了一些奇怪的行为: 如果json如下:

{"data":{"oneSlash":"aaa\bbb","twoSlashes":"ccc\\ddd","threeSlashes":"eee\\\fff"}}

查询的结果是:

{"oneSlash":"aaabbb","twoSlashes":"ccc\\ddd","threeSlashes":"eee\\fff"}

我理解“oneSlash”和“threeSlashes”的结果,但为什么“twoSlashes”不等于“ccc\ddd”? 毕竟 '\' 应该不转义为 '\'

顺便说一句,查询是:

SELECT get_json_object(escaping_test.data, '$.data') FROM escaping_test

【问题讨论】:

    标签: json hive


    【解决方案1】:

    这是因为 \b 和 \f 是有效的转义字符,而 \d 不是。有一篇更详细的帖子:Where can I find a list of escape characters required for my JSON ajax return type?

    【讨论】:

      猜你喜欢
      • 2020-01-13
      • 2021-12-08
      • 2017-07-15
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-08-04
      • 2011-10-04
      • 2015-03-16
      相关资源
      最近更新 更多