hive get_json_object() 解析嵌套json字符串

测试 数据为:

line=
{
“store”:
{
“fruit”:[{“weight”:9,“type”:“apple”}, {“weight”:10,“type”:“pear”}],
“bicycle”:{“price”:20,“color”:“red”}
},
“email”:“leaves@json_udf_test.net”,
“owner”:“leaves”
}
get单层值

hive> select  get_json_object(line, '$.owner') from test;

结果:leaves

get多层值.

hive> select  get_json_object(line, '$.store.bicycle.price') from test;

结果:20

get数组值[]

hive> select  get_json_object(line, '$.store.fruit[0]') from test;

结果:{“weight”:9,“type”:“apple”}

hive (test)> select get_json_object(line,'$.store.fruit[0].weight') from json_test;

结果:9

你可能感兴趣的:(hive,hive,获取嵌套json的值)