JSON parser for Talend

天涯浪子 提交于 2019-11-28 14:12:26

Have you tried creating a custom routine? You can do so under Code (in the repository window on the left), right click on Routines and create your custom routine. This lets you write a Java function which can then be called from somewhere in your job (tMap, tJava, whatever). You could read your input file and call a function on each line/element or whatever that does something you want.

Like any Java function, the routine can then write to file, print to screen or return some list object that you can further work on in another tJava, tJavaFlex, tJavaRow or whatever Talend components in your job.

It may feel a little hacky, but you can do a lot just using custom routines.

If you want to go all the way and create your own component, this may be a good way to start: http://www.talendforge.org/forum/viewtopic.php?id=17650 Of course, creating components is much more time-consuming, but may be useful if you think you'll be reusing this code in multiple projects/cases.

Read the file line by line, and construct a JSON Object for each line.

final BufferedReader br = new BufferedReader(new FileReader(file));
String line;

while ((line = br.readLine()) != null)         // read until EOF
{
  final JSONObject json = new JSONObject(line);
  ...
}

br.close();
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!