I have CDT with following fields
Expresion: - a!localVariables( local!data: 'type!{urn:com:appian:types:RS}RS_dummyCDT'(id: 1, name: "abc"), a!toJson(local!data))
Result:
Note: If I use parameter removeNullOrEmptyFields as true, it also excluding text fields which are null
a!localVariables( local!data: 'type!{urn:com:appian:types:RS}RS_dummyCDT'(id: 1, name: "abc"), a!toJson( value: local!data, removeNullOrEmptyFields: true ))
Expression: a!localVariables( local!data: 'type!{urn:com:appian:types:RS}RS_dummyCDT'(id: 1, name: "abc"), a!toJson_17r1(local!data ))
I want to get the data the way we are getting result while using a!toJson_17r1. i.e. I want to get all the fields of CDT irrespective of NULL value.
Is there any way to achieve this using a!toJson?
Discussion posts and replies are publicly visible
I think they just improved the definition of the function to remove the null values. How about keep using the a!toJson_17r1 function?
I am concerned if a!toJson_17r1 get deprecated in future.
Handling of non-populated field in JSON is a very controversial topic. There is no real right or wrong.
Do you have any specific requirement from the API you are talking to?
I recommend to not use old versions of functions for new developments.
Hi
Yes, we do have specific requirement to pass attributes even though value of the attribute is null.
Is there any solution or work around for this issue?
Interesting. I did a quick test, and casting the CDT to a Map before the transformation seems to include empty fields. Maybe you wanna test this.
a!toJson( cast( type!Map, 'type!{urn:com:appian:types:AA}AA_Vehicle'( vehicleId: 1 ) ) )