You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@flink.apache.org by daviD <du...@yahoo.com> on 2016/11/17 19:59:14 UTC
fileInpuFormat of type json
Hello,
Does the Flink Scala api have a method for reading json files? If not, are there any examples on how this is accomplished?
Thanks
-daviD
Re: fileInpuFormat of type json
Posted by Fabian Hueske <fh...@gmail.com>.
Hi,
there are no built-in methods to read JSON.
How this can be done depends on the formatting of the JSON.
If you have a collection of JSON objects which are separated by newline
(and there are no other newlines) you can read the file with
env.readTextFile().
This will give you one String per line which can be parsed in a subsequent
RichMapFunction. If you do that, you should make sure that the parser is
initialized once (in open()) and not for every call of map().
Best, Fabian
2016-11-17 20:59 GMT+01:00 daviD <du...@yahoo.com>:
> Hello,
>
> Does the Flink Scala api have a method for reading json files? If not, are
> there any examples on how this is accomplished?
>
> Thanks
>
> -daviD
>