-- hive中解析json數組 select t1.status ,substr(ss.col,1,10) as col ,t3.evcId ,t3.evcLicense ,t3.evcAddress ,t3.modelName from ( select get_json_object(json,"$.status") as status ,split( regexp_replace( regexp_extract( get_json_object(json,"$.data") -- 獲取data數組,格式[{json},{json}] ,'^\\[(.+)\\]$' ,1 ) -- 刪除字符串前后的[],格式{json},{json} ,'\\}\\,\\{' , '\\}\\|\\|\\{' ) -- 將josn字符串中的分隔符代換成||,格式{json}||{json} ,'\\|\\|' ) as str -- 按||分隔符切割成一個hive數組 from tmp_json_test ) t1 lateral view explode(t1.str) ss as col -- 將hive數組轉成行 lateral view json_tuple(ss.col,'evcId','evcLicense','evcAddress','modelName') t3 as evcId,evcLicense,evcAddress,modelName ;