See Also: Studio Meta-Data Tags
Used to designate an alternate name to Struct members that is used when serializing and deserializing structs to and from JSON and XML.
Struct Members
{ Name={ Alternate Name to be Used for Serializing and Deserializing } }
This allows developers to use different internal and external names for Struct members for use with web services. This alternate name is used when serializing and deserializing that Struct member to and from JSON and XML for use with web services that require a different name for members than is used internally. This works with cJsonObject and cWebService classes and the DataFlex tools that serialize and deserialize web services.
This sample code shows how to give an external name of "Number" to a struct member that is a reserved word in DataFlex.
Struct tMyStruct
Integer iItemId
{ Name="Number" }
Integer iQuantity
End_Struct
Function GenerateJson Returns String
Handle hoJson
tMyStruct data
String sResult
Get Create (RefClass(cJsonObject)) to hoJson
Move 24 to data.iItemId
Move 5 to data.iQuantity
Send DataTypeToJson of hoJson data
Set peWhiteSpace of hoJson to jpWhitespace_Spaced
Get Stringify of hoJson to sResult
Send Destroy of hoJson
Function_Return sResult
End_Function
generates the following JSON:
{ "iItemId": 24, "Number": 5 }