@JsonFixElement ( serialNum ; param )
A helper for the native function JSONSetElement() to force objects appear in the order you set them.
Be the first to rate this function Log in to vote
Alex Zueiv - Show more from this author
Tashkent |
"native: " & JSONSetElement ( "" ; [ "b" ; 1 ; 0 ] ; [ "a" ; 2 ; 0 ] ) ;
"---" ;
"fixed: " & Let (
JSN = JSONSetElement ( "" ;
[ @JsonFixElement ( 1 ; "b" ) ; 1 ; 0 ] ;
[ @JsonFixElement ( 2 ; "a" ) ; 2 ; 0 ]
) ;
List (
@JsonFixElement ( 0 ; JSN ) ;
@JsonFixElement ( 0 ; JSONFormatElements ( JSN ) )
)
)
)
---
fixed: {"b":1,"a":2}
{
"b" : 1,
"a" : 2
}
Function definition: (Copy & paste into FileMaker's Edit Custom Function window)
A helper for the function JSONSetElement(). Fixes objects in the order you set them.
Allows to build JSON requests for APIs like Authorize.Net that requires the ordering of elements to match the API Reference (see https://developer.authorize.net/api/reference/).
Non-recursive. Requires FM 16 or greater (no runtimes).
Can be used with another my wrapper CF to produce an aligned JSON structure with a custom object sort order:
@JsonFixElement ( 0 ; @JsonFormatElements ( fixedJSON ) )
https://www.briandunning.com/cf/2130
Comments
Note: these functions are not guaranteed or supported by BrianDunning.com. Please contact the individual developer with any questions or problems.