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?
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)}');
DUMP a;
I get an empty result:
()

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

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,
Ruslan