{ ...">
美文网首页
get_json_object()的用法

get_json_object()的用法

作者: 大道至简_6a43 | 来源:发表于2020-06-10 08:56 被阅读0次

hive> select get_json_object('{

    >  "store":

    >        {

    >          "fruit":[{"weight":8,"type":"apple"}, {"weight":9,"type":"pear"}], 

    >          "bicycle":{"price":19.95,"color":"red"}

    >          },

    >  "email":"amy@only_for_json_udf_test.net",

    >  "owner":"amy"

    > }','$.store.fruit[0].weight');

OK

8

Time taken: 0.141 seconds, Fetched: 1 row(s)

hive> select get_json_object('{

    >  "store":

    >        {

    >          "fruit":[{"weight":8,"type":"apple"}, {"weight":9,"type":"pear"}], 

    >          "bicycle":{"price":19.95,"color":"red"}

    >          },

    >  "email":"amy@only_for_json_udf_test.net",

    >  "owner":"amy"

    > }','$.store.fruit[1].type');

OK

pear

hive> select get_json_object('{

    >  "store":

    >        {

    >          "fruit":[{"weight":8,"type":"apple"}, {"weight":9,"type":"pear"}], 

    >          "bicycle":{"price":19.95,"color":"red"}

    >          },

    >  "email":"amy@only_for_json_udf_test.net",

    >  "owner":"amy"

    > }','$.store.fruit.type');

OK

["apple","pear"]

Time taken: 0.137 seconds, Fetched: 1 row(s)

get_json_object中对于外层的直接'$.key.key[index].key2'; index对应数组中第几个json,key2对应数组中json的key;

相关文章

网友评论

      本文标题:get_json_object()的用法

      本文链接:https://www.haomeiwen.com/subject/cqhutktx.html