简体   繁体   中英

equals cannot convert from String to boolean

I want to compare input String from Database in tMap component in Talend Open Studio. If my String is equal to "{}", I want to put there "nodata" string. Otherwise I leave the original input as it is.

My code in expression/filter in tMap:

(row1.parameter).equals("{}")?"nodata":row1.parameter

Error I'm getting:

Detail Message: Type mismatch: cannot convert from String to boolean

Do you have any suggestions?

Try to assign the result to a String variable, like

String someVariable = row1.parameter.equals("{}") ? "nodata" : row1.parameter;

because your expression returns a String… Are you assigning it to a Boolean? If yes, that will cause / be a type mismatch.

Assuming you're keeping the "Parameter" field, it sounds like your Output field that you are assigning 'Parameter' to is not a 'String' field, and is set as 'Boolean':

在此处输入图片说明

So the first point of call would be to check/change the output to a type of 'String':

在此处输入图片说明

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM