Reputation: 74
I have the following type of json file:
{"employees":[
{"firstName":"John", "lastName":"Doe"},
{"firstName":"Anna", "lastName":"Smith"},
{"firstName":"Peter", "lastName":"Jones"}
]}
I am trying to execute the following pig script to load json data
A = load 'pigdemo/employeejson.json' using JsonLoader ('employees:{(firstName:chararray)},{(lastName:chararray)}');
getting error!!
Unable to recreate exception from backed error: Error: org.codehaus.jackson.JsonParseException: Unexpected end-of-input: expected close marker for ARRAY (from [Source: java.io.ByteArrayInputStream@1553f9b2; line: 1, column: 1]) at [Source: java.io.ByteArrayInputStream@1553f9b2; line: 1, column: 29]
Upvotes: 0
Views: 700
Reputation: 5260
First the reason that you see Unexpected end-of-input
is because each recode should be in 1 line - like this :
{"employees":[{"firstName":"John", "lastName":"Doe"}, {"firstName":"Anna", "lastName":"Smith"}, {"firstName":"Peter", "lastName":"Jones"}]}
Now - since each row is employees list run the next command
A = load '$flurryData' using JsonLoader ('employees:bag {t:tuple(firstName:chararray, lastName:chararray)}');
describe A;
dump A;
Give the next output
A: {employees: {t: (firstName: chararray,lastName: chararray)}}
({(John,Doe),(Anna,Smith),(Peter,Jones)})
Hope this help !
Upvotes: 1