我有一个json文件,格式如下
[
{
"id": 2,
"createdBy": 0,
"status": 0,
"utcTime": "Oct 14, 2014 4:49:47 PM",
"placeName": "21/F, Cunningham Main Rd, Sampangi Rama NagarBengaluruKarnatakaIndia",
"longitude": 77.5983817,
"latitude": 12.9832418,
"createdDate": "Sep 16, 2014 2:59:03 PM",
"accuracy": 5,
"loginType": 1,
"mobileNo": "0000005567"
},
{
"id": 4,
"createdBy": 0,
"status": 0,
"utcTime": "Oct 14, 2014 4:52:48 PM",
"placeName": "21/F, Cunningham Main Rd, Sampangi Rama NagarBengaluruKarnatakaIndia",
"longitude": 77.5983817,
"latitude": 12.9832418,
"createdDate": "Oct 8, 2014 5:24:42 PM",
"accuracy": 5,
"loginType": 1,
"mobileNo": "0000005566"
}
]
当我尝试使用jsonloader类将数据加载到pig时,我得到了一个错误,比如输入的意外结束:object的expected close marker
a = LOAD '/user/root/jsoneg/exp.json' USING JsonLoader('id:int,createdBy:int,status:int,utcTime:chararray,placeName:chararray,longitude:double,latitude:double,createdDate:chararray,accuracy:double,loginType:double,mobileNo:chararray');
b = foreach a generate $0,$1,$2;
dump b;
1条答案
按热度按时间7kqas0il1#
以前我也遇到过类似的问题,后来我知道pigjson不支持多行json格式。它总是希望json输入必须是单行的。
我建议您使用elephantbird json加载程序,而不是本机jsonloader。它非常适合jsons格式。
您可以从下面的链接下载jar
我将您的输入格式改为单行,并通过elephantbird加载,如下所示