how can I set a multiline string in pig latin?
I'm trying to set a string containing a JSON inside it. something like this:
myjson = '
{
"name":"someone",
"age":"20"
}
';
how can I set a multiline string in pig latin?
I'm trying to set a string containing a JSON inside it. something like this:
myjson = '
{
"name":"someone",
"age":"20"
}
';
A linebreak can be added with a linebreak character (\n
or \r\n
). The impact of having a linebreak depends on what you do with your data later on. (It will not automatically fill two rows in your table).
That being said, you could also just create (valid) single line JSON, and format it afterwards. Especially if you want more than simple linebreaks you would not want to do the formatting in Pig.
To conclude, you can also try to use existing solutions for handling JSON, for instance the JsonStorage class described here.