Home | About | Sematext search-lucene.com search-hadoop.com
 Search Hadoop and all its subprojects:

Switch to Threaded View
Pig, mail # user - Builtin JsonLoader: how to load a flat array?

Copy link to this message
Builtin JsonLoader: how to load a flat array?
Ruslan Al-Fakikh 2013-04-05, 03:44
Hey guys,

I have a complex json file, I can load simple properties, but I am having
problems with a property that has an array as its value:
Suppose I have input.json with the contents:
{"images": ["url1","url2"]}

when i do:
a = LOAD 'input.json' using JsonLoader('images: {(image: chararray)}');
I get an empty result:

However, if the input.json is this:
{"images": [{"image":"url1"},{"image":"url2"}]}
then the ouput is fine:

But I can't change the format of the input file. I've tried a lot of syntax
tricks, but failed to find a workaround how to load a flat array, not the
array of objects.

Is there a limitation in the builtin JsonLoader? Should it be able to load
any json file, provided I specify a correct schema?

Best Regards,