我需要在得分后提取浮点数。
{"reason_desc":
{
"score":"0.1",
"numOfIndicatrix":"0",
"indicatrix":[]},
"success":true,
"id":"1555039965661065S427A2DCF5787920"
}
我希望输出0.1或任何用“”括起来的数字。
答案 0 :(得分:1)
答案 1 :(得分:1)
您无需在Hive中使用regexp解析JSON,它具有相同的嵌入式功能:
with your_table as (--use your table instead of this
select '{"reason_desc":
{
"score":"0.1",
"numOfIndicatrix":"0",
"indicatrix":[]},
"success":true,
"id":"1555039965661065S427A2DCF5787920"
}' as json_col
)
select get_json_object(t.json_col,'$.reason_desc.score') as score
from your_table t
结果:
0.1
另请参阅:json_tuple