Solved

"if": {fme:get-list-attribute("_list{}.IDENTIFICERENDE WAARDE") = "R"} , "then": {"amount" : @Value(_list{1}.BDRG_NETTO)} If i use this in jason templater it yields following "if" : true, "then" : { "amount" : 10000 }


Badge +3

Which i then replace with regexp.

How can i have it just yield following result?

 "amount" : 10000

 

I'd like to have it solved inthe Templater rather then resorting to regexp clean-up.

 

 

Tx in advance to all.

icon

Best answer by debbiatsafe 28 April 2022, 23:53

View original

2 replies

Userlevel 3
Badge +17

Hello @gio​ 

As the if then keywords are quoted, they are added to the JSON output.

Try the following XQuery expression in the JSONTemplater to get the desired output.

{if(fme:get-list-attribute("_list{}.IDENTIFICERENDE WAARDE") = "R")
then {"Value": @Value(_list{1}.BDRG_NETTO)}
else {}}

I hope this information helps.

Badge +3

Hi Debbie

 

Yes it helped.

Also i found out, after i asked the question that my snippet is javascript en not jason script.

Indeed i needed to take the if then out of the json part.

 

I have it like this now and it does it's job.

 

Ill SaS your answer.

 

"amount":

{

  {  if(fme:get-list-attribute("_list{}.IDENTIFICERENDE WAARDE") = "R")

    then { @Value(_list{1}.BDRG_NETTO)}

    else {}}

}

 

 

tx for help.!

 

 

 

Reply