3

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"
    }
';
user3175226
  • 3,579
  • 7
  • 28
  • 47
  • 1
    It doesn't answer your question directly but if you wanna read Json with Pig, you might wanna read http://stackoverflow.com/questions/5013003/how-do-i-parse-json-in-pig – merours Jun 24 '14 at 12:43
  • Have you tried putting \n in your strings when line break is necessary? – vicsana1 Oct 23 '14 at 13:45

1 Answers1

0

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.

Community
  • 1
  • 1
Dennis Jaheruddin
  • 21,208
  • 8
  • 66
  • 122