You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@flink.apache.org by Flavio Pompermaier <po...@okkam.it> on 2018/11/20 17:27:36 UTC

Flink JSON (string) to Pojo (and vice versa) example

Hi everybody,
since here at Okkam we didn't find any "native" Flink map functions that
already permit to pass from JSON strings to POJOs (and vice versa), we
decided to share with the Flink community a simple implementation for these
2 tasks:
 - JSON (string) to POJO [1]
 - POJO to JSON (string) [2].
A Flink Main class that use those 2 functions can be found at [1].

Any feedback is welcome!

Best,
Flavio

[1]
https://github.com/okkam-it/flink-examples/blob/master/src/main/java/it/okkam/flink/Json2PojoExample.java
[2]
https://github.com/okkam-it/flink-examples/blob/master/src/main/java/it/okkam/flink/json/JsonStringToPojo.java
[3]
https://github.com/okkam-it/flink-examples/blob/master/src/main/java/it/okkam/flink/json/Pojo2JsonString.java

Re: Flink JSON (string) to Pojo (and vice versa) example

Posted by Fabian Hueske <fh...@gmail.com>.
Thanks Flavio.
This looks very useful.

AFAIK, the Calcite community is also working on functions for JSON <-> Text
conversions which are part of SQL:2016.
Hopefully, we can leverage their implementations in Flink's SQL support.

Best, Fabian

Am Di., 20. Nov. 2018 um 18:27 Uhr schrieb Flavio Pompermaier <
pompermaier@okkam.it>:

> Hi everybody,
> since here at Okkam we didn't find any "native" Flink map functions that
> already permit to pass from JSON strings to POJOs (and vice versa), we
> decided to share with the Flink community a simple implementation for these
> 2 tasks:
>  - JSON (string) to POJO [1]
>  - POJO to JSON (string) [2].
> A Flink Main class that use those 2 functions can be found at [1].
>
> Any feedback is welcome!
>
> Best,
> Flavio
>
> [1]
> https://github.com/okkam-it/flink-examples/blob/master/src/main/java/it/okkam/flink/Json2PojoExample.java
> [2]
> https://github.com/okkam-it/flink-examples/blob/master/src/main/java/it/okkam/flink/json/JsonStringToPojo.java
> [3]
> https://github.com/okkam-it/flink-examples/blob/master/src/main/java/it/okkam/flink/json/Pojo2JsonString.java
>