You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@flink.apache.org by Alexander Smirnov <al...@gmail.com> on 2016/04/26 03:50:35 UTC

convert Json to Tuple

Hello everybody!

my RMQSource function receives string with JSONs in it.
Because many operations in Flink rely on Tuple operations, I think it is a
good idea to convert JSON to Tuple.

I believe this task has been solved already :)
what's the common approach for this conversion?

Thank you,
Alex

Re: convert Json to Tuple

Posted by Alexander Smirnov <al...@gmail.com>.
Thanks Timur!

I should have mentioned, I need it for Java

On Mon, Apr 25, 2016 at 10:13 PM Timur Fayruzov <ti...@gmail.com>
wrote:

> Normally, Json4s or Jackson+scala plugin work well for json to scala data
> structure conversions. However, I would not expect they support a special
> case for tuples, since JSON key-value fields would normally convert to case
> classes and JSON arrays are converted to, well, arrays. That's being said,
> StackOverflow to the rescue:
> http://stackoverflow.com/questions/31909308/is-it-possible-to-parse-json-array-into-a-tuple-with-json4s
>
> I didn't try the approach myself, though.
>
> On Mon, Apr 25, 2016 at 6:50 PM, Alexander Smirnov <
> alexander.smirnoff@gmail.com> wrote:
>
>> Hello everybody!
>>
>> my RMQSource function receives string with JSONs in it.
>> Because many operations in Flink rely on Tuple operations, I think it is
>> a good idea to convert JSON to Tuple.
>>
>> I believe this task has been solved already :)
>> what's the common approach for this conversion?
>>
>> Thank you,
>> Alex
>>
>
>

Re: convert Json to Tuple

Posted by Timur Fayruzov <ti...@gmail.com>.
Normally, Json4s or Jackson+scala plugin work well for json to scala data
structure conversions. However, I would not expect they support a special
case for tuples, since JSON key-value fields would normally convert to case
classes and JSON arrays are converted to, well, arrays. That's being said,
StackOverflow to the rescue:
http://stackoverflow.com/questions/31909308/is-it-possible-to-parse-json-array-into-a-tuple-with-json4s

I didn't try the approach myself, though.

On Mon, Apr 25, 2016 at 6:50 PM, Alexander Smirnov <
alexander.smirnoff@gmail.com> wrote:

> Hello everybody!
>
> my RMQSource function receives string with JSONs in it.
> Because many operations in Flink rely on Tuple operations, I think it is a
> good idea to convert JSON to Tuple.
>
> I believe this task has been solved already :)
> what's the common approach for this conversion?
>
> Thank you,
> Alex
>