Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Description:
My job: (Talend v5.6)
product_description field on json = ["aaa" , "bbb" , "ccc" , "dd,ee" , "ac, bd ,ef"] (***)
Using tExtractJSONField to load (***) and check "Is Array", convert to "String, List, Object"
In tMap, I try with data type: String, List, Object ... to mapping product_description
And result after mapping = [aaa , bbb , ccc , dd,ee , ac, bd ,ef]
Problems:
1/ I search on google about LIST type in Talend, but can not understand .
2/ I try to make data after loading like:
aaa
bbb
ccc
dd,ee
ac, bd ,ef
Edit:
From Talend document
--> Is Array: select this check box when the JSON field to be extracted is an array instead of an object.
But what kind of "an array" , string array or list or array list ...
Thanks.
public static String convertToString( List input) {
String rs = "";
try {
for(int i = 0; i< input.size(); i++)
{
rs = rs + input.get(i) + "\n";
}
} catch (Exception e) {
//System.out.println (e.getMessage());
}
return rs;
}
public static int convertToString( String input) {
String[] ary = input.split(","); -- this is line 38
return ary.length;
}
Exception in component tMap_10
java.lang.NullPointerException
at routines.convert_type.convertToString(convert_type.java:38)
at ......
public static String convertToString( List input) {
String rs = "";
try {
for(int i = 0; i< input.size(); i++)
{
rs = rs + input.get(i) + "\n";
}
} catch (Exception e) {
//System.out.println (e.getMessage());
}
return rs;
}