You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@pig.apache.org by Ruslan Al-Fakikh <me...@gmail.com> on 2013/04/05 05:44:44 UTC

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