Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Write Table now available in Qlik Cloud Analytics: Read Blog
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

[resolved] Convert LIST to String

Description:

My job: (Talend v5.6)

0683p000009MGlT.png
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"

0683p000009MGlY.png

In tMap, I try with data type: String, List, Object ... to mapping product_description

0683p000009MGlU.png

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.

Labels (2)
1 Solution

Accepted Solutions
Anonymous
Not applicable
Author

I am sorry about my mistake.
Because of null value in product_description , so I got errors above. 

Here my code:


    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;
    }

View solution in original post

2 Replies
Anonymous
Not applicable
Author

I write a simple routine with input = product_description ( [color=#5b5b5d][size=1][font=Verdana, Helvetica, Arial, sans-serif][aaa , bbb , ccc , dd,ee , ac, bd ,ef] [/font][/size][/color]😞

    public static int convertToString( String input) {
    String[] ary = input.split(","); -- this is line 38
    return ary.length;
    }


But it gets errors:

Exception in component tMap_10
java.lang.NullPointerException
at routines.convert_type.convertToString(convert_type.java:38)
at  ......


 I am curious about this problem and trying to fix.
Anonymous
Not applicable
Author

I am sorry about my mistake.
Because of null value in product_description , so I got errors above. 

Here my code:


    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;
    }