JSON Functions, MBS vs. FM16
But maybe you want to take a second look on how long you may wait for bigger JSON data sets. We usually use XML and JSON import/export not for 3 records, but for thousands. We automate data exchange with other services and so we need to process 1000s of records. MBS Plugin functions are built for speed, so we prefer to use the JSON reference numbers. Parse the data once, get a number and query it often. The FileMaker functions do not keep the parsed data and do the parsing for each query. With MBS Plugin we can use reference numbers, so even for building large JSON data sets, you can avoid producing text for each step and parse it again to add the next value.
Finally you need to know that JSONGetElement always returns text. This may be fine first, but can get you in serious trouble later. For example if you take this formula:
GetAsNumber(JSONGetElement ( "[ 10, 20.5, 30]" ; 1 ))
The text returned is "20.5", but you need 20.5 as a numeric value. Because if you later want to process it, you may need a number. Now GetAsNumber will take the "20.5" and convert it to 20.5 on a typical US system. But with German localization, we actually get 205. The dot is ignored as the German functions require a comma as decimal separator. MBS Plugin provides values in the correct types like boolean, numbers and text. If you like, use FM.DataType function to check what type a value has.
Feature | MBS JSON Functions | FileMaker’s JSON Functions |
---|---|---|
Number of functions | 59 | 6 |
Available in FileMaker Versions | FileMaker 7 to 16 | FileMaker 16 only |
FileMaker Pro (Advanced) | yes | yes |
Runtime Apps | yes | no |
FileMaker Go | no | yes |
FileMaker iOS SDK | yes | yes |
FileMaker Server | yes | yes |
Create arrays and objects | yes | yes |
Delete elements | yes | yes |
Format | yes | yes |
List Keys | yes | yes |
Get/Set Values | yes | yes |
Parse once, Query often | yes | no |
JSON Import with field/table creation | yes | no |
Return data types | boolean, number or text | always text |
Create Array with 2000 entries | 162ms | 1792ms |
Get Values from Array with 2000 entries | 195ms | 2364ms |
Your time measurements will vary (and please deactivate Trace log), but in general not parsing and formatting JSON 2000 times in a loop saves a lot of time.
FileMaker's functions are great as a base and certainly help all the beginners getting started with JSON and REST services. If you need more speed or more features, feel free to test our MBS Plugin.
And if you miss something, let me know.
PS: Some of this issues with returning numbers have been improved in 16.0.2 release of FileMaker.