@JsonFixElement ( serialNum ; param )
A helper for the native function JSONSetElement() to force objects appear in the order you set them.
Average rating: 5.0 (1 vote) Log in to vote
Alex Zueiv - Show more from this author
Tashkent https://github.com/zueiv |
"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
Frederic Bruckert Apr 8, 2024 |
||
Great ! !! Thanks you so much. This CF is so important to keep order in json object when we retrieve datas from Filemaker, to display them in ordered tables on a web site. | ||
Note: these functions are not guaranteed or supported by BrianDunning.com. Please contact the individual developer with any questions or problems.