Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
In the JSON file, some rows don't have the column date as below sample
{"id":3,"name":"PRGN","Date_End":"2019-04-08T11:52:45.000Z"}
{"id":9,"name":"FXUL10"}Below is the logic I am using in the job
tFileInputDelimited>tExtractJSONFields>tMap>tFileOutputDelimited
Date_End is a string data type in the data source
In the tMap I used below logic
Then I tried:
(row2.Date_End.equals(""))||(row2.Date_End==null) ? null :
(TalendDate.parseDate("EEE MMM dd HH:mm:ss Z yyyy",row2.Date_End))Output Result:
java.lang.NullPointerException
Hi @Karuetl
Could you please try like below?
Relational.ISNULL(row2.Date_End) || row2.Date_End.equals("")? null :
(TalendDate.parseDate("EEE MMM dd HH:mm:ss Z yyyy",row2.Date_End))
Warm Regards,
Nikhil Thampi
Please appreciate our Talend community members by giving Kudos for sharing their time for your query. If your query is answered, please mark the topic as resolved 🙂
Hello,
What does the output look like from tExtractJSONFields? Could you please use tLogRow behind tExtractJSONFields to print out it on console?
Best regards
Sabrina
Then I tried:
(row2.Date_End.equals(""))||(row2.Date_End==null) ? null :
(TalendDate.parseDate("EEE MMM dd HH:mm:ss Z yyyy",row2.Date_End))
Swap the order of the End_Date tests so you check ==null first, then it will skip the .equals("") if it's null.
Another way to do the same thing is (row2.Date_End==null ? "" : row2.Date_End).equals("") ? ... which is a bit like a SQL coalesce() function.
Hi @Karuetl
Could you please try like below?
Relational.ISNULL(row2.Date_End) || row2.Date_End.equals("")? null :
(TalendDate.parseDate("EEE MMM dd HH:mm:ss Z yyyy",row2.Date_End))
Warm Regards,
Nikhil Thampi
Please appreciate our Talend community members by giving Kudos for sharing their time for your query. If your query is answered, please mark the topic as resolved 🙂