表字段中jsonStr是一个json格式的字符串,类似于map结构。{"name”:"king", "age":18, "score":99}

使用str_to_map可以转化为map结构。

str_to_map(regexp_replace(regexp_replace(regexp_replace(jsonStr,'\"',''),'\\{',''),'\\}',''), ',', ':') as json_map,

 

如果jsonStr是控制,则需要使用if添加判断

if(jsonStr is null or jsonStr = '',map(),str_to_map(regexp_replace(regexp_replace(regexp_replace(jsonStr,'\"',''),'\\{',''),'\\}',''), ',', ':')) as json_map,

 针对map结构的解析成多行形式

select pk_day,x_k,x_v
from tmp_b 
lateral view outer explode(json_map) x as x_k,x_v

 

相关文章:

  • 2021-08-23
  • 2021-08-29
  • 2022-01-26
  • 2022-12-23
  • 2021-05-27
  • 2021-04-06
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-11-27
  • 2022-12-23
  • 2021-10-03
  • 2021-07-03
相关资源
相似解决方案