我有一个json和价值的json
000000,{"000":{"phoneNumber":null,"firstName":"xyz","lastName":"pqr",“email@xyz.com”,"alternatePickup":true,"sendTextNotification":false,"isSendTextNotification":false,"isAlternatePickup":true}}
我试着用象鸟装载机把这个json装进猪体内,但做不到。
我能够加载以下json
{"000":{"phoneNumber":null,"firstName":"xyz","lastName":"pqr",“email@xyz.com”,"alternatePickup":true,"sendTextNotification":false,"isSendTextNotification":false,"isAlternatePickup":true}}
使用以下脚本-
REGISTER json-simple-1.1.1.jar;
REGISTER elephant-bird-pig-4.3.jar;
REGISTER elephant-bird-hadoop-compat-4.3.jar;
json_data = load 'ek.json' using com.twitter.elephantbird.pig.load.JsonLoader() AS (json_key: [(phoneNumber:chararray,firstName:chararray,lastName:chararray,email:chararray,alternatePickup:boolean,sendTextNotification:boolean,isSendTextNotification:boolean,isAlternatePickup:boolean)]);
dump json_data;但是当我把价值包含在json中时
json_data = load 'ek.json' using com.twitter.elephantbird.pig.load.JsonLoader() AS (id:int,json_key: [(phoneNumber:chararray,firstName:chararray,lastName:chararray,email:chararray,alternatePickup:boolean,sendTextNotification:boolean,isSendTextNotification:boolean,isAlternatePickup:boolean)]);不管用!!提前感谢你的帮助。
发布于 2018-05-16 05:34:19
JsonLoader只允许加载正确的json,而您的格式实际上是CSV。通过增加复杂性,您可以选择三个选项:
发布于 2018-05-16 06:21:39
您可以使用内置的JsonStorage和JsonLoader()
a = load 'a.json' using JsonLoader('a0:int,a1:{(a10:int,a11:chararray)},a2:(a20:double,a21:bytearray),a3:[chararray]'); 在本例中,数据是在没有模式的情况下加载的;它假定输入目录中有一个.pig_schema (由JsonStorage生成)。
a = load 'a.json' using JsonLoader(); https://stackoverflow.com/questions/50298219
复制相似问题