Brian Dunning's FileMaker Custom Functions

JSONSqlQueryResult ( fieldlist ; keylist ; keytypes ; clauses )

Execute SQL-statement and format directly into JSON, without dependencies (for fmp 18+)

  Average rating: 4.0 (1 vote) Log in to vote

Menno van Beek   Menno van Beek - Show more from this author
Van Beek Zakelijke Software
https://www.vbzs.nl

Share on Facebook Share on Twitter

  Sample input:
JSONSqlQueryResult (
List (
GetFieldName ( SalesLines::Number ) ;
GetFieldName ( SalesLines::Description ) ;
GetFieldName ( SalesLines::Price ) ;
GetFieldName ( SalesLines::Amount ) ) ;
"" ; /* keylist may be left empty, see description in function */
"" ; /* keytypeslist may be left empty */
"FROM \"SalesLines\" WHERE \"SalesLines\".\"SalesID\"=123456" )
  Sample output:
[
{
"Amount" : 10,
"Description" : "item",
"Number" : 1,
"Price" : 10
},
{
"Amount" : 27,
"Description" : "items",
"Number" : 3,
"Price" : 9
}
]

  Function definition: (Copy & paste into FileMaker's Edit Custom Function window)

This function is intended for straightforward SQL-statements and to have the result poured directly into JSON-format. The function requires fmp 18+ and does not depend on any other custom-function.

Supply at least a list of "Fully Quallified Field Names" and a FROM and WHERE clause. The function will then create the keynames from the fieldlist, but you can also set your own keylist.
The same for the keytypes. Provide a list with only JSONString and JSONNumber values or leave it empty to have the function choose by checking the fieldtypes.

 

Comments

Log in to post comments.

 

Note: these functions are not guaranteed or supported by BrianDunning.com. Please contact the individual developer with any questions or problems.

Support this website.

This library has been a free commmunity resource for FileMaker users and developers for 18 years. It receives no funding and has no advertisements. If it has helped you out, I'd really appreciate it if you could contribute whatever you think it's worth: