对于hive对JSON字符串的解析小白在之前博文中已经有两篇做过详细的介绍了,这边博文主要记录一下,小白在工作中遇到的一个实例,巨坑。
案例如下:
{"id":"23|38","index":"1","name":"高星好评","subfilters":,"type":"23"}
一眼看上去,是不是符合JSON字符串的风格,然后就开始解析
select filters,
id,
index,
name,
type
from aa
lateral view json_tuple(filters, 'id', 'index', 'name', 'type') b
as id,
index,
name,
type
结果为:

百思不得其解,为什么明明有数据,解析不出来呢?
仔细看{"id":"23|38","index":"1","name":"高星好评","subfilters":,"type":"23"}中"subfilters":,这个地方和别的不一样,像是缺了一个引号,那么抱着试试看的想法,试一下:
select filters,
id,
index,
name,
type
from aa
lateral view json_tuple(regexp_replace(filters,'\\"subfilters\\"\\:\

最低0.47元/天 解锁文章
908

被折叠的 条评论
为什么被折叠?



