AnsweredAssumed Answered

JSONSetElement - Conditional Include Logic

Question asked by fmdataweb on Nov 29, 2018
Latest reply on Nov 29, 2018 by comment

I'm creating some JSON data using the JSONSetElement function successfully as follows:

 

Let([

 

~json = JSONSetElement ( "" ;

 

["address1"; Addresses::Address1; JSONString ];

["address2"; Addresses::Address2; JSONString ];

["company"; Addresses::Company; JSONString ];

["country"; Addresses::Country; JSONString ];

["city"; Addresses::City; JSONString ]

];

 

JSONSetElement( $addresses ; $counter ; ~json ; JSONObject )

)

 

I now need to add the following:

 

["id"; Addresses::ID; JSONNumber ];

 

but only add this if the Addresses::ID field is NOT empty. I haven't been able to work out the syntax for this to do this in the one calculation - anyone know if this is possible within a single calculation to conditionally include some JSON?

Outcomes