Topics   All   MacOS (Only)   Windows (Only)   Linux (Only, Not)   iOS (Only, Not)  
Components   Crossplatform Mac & Win   Server   Client   Old   Deprecated   Guides   Examples   Videos
New in version: 9.4   9.5   10.0   10.1   10.2   10.3   10.4   10.5   11.0   11.1    Statistic    FMM    Blog  

FM.SQL.JSONRecord

Returns a row as JSON object.

Component Version macOS Windows Linux Server FileMaker iOS SDK
FM FMSQL JSON 8.1 Yes Yes Yes Yes Yes
MBS( "FM.SQL.JSONRecord"; SQLref; Row; FieldNames { ; Flags } )   More

Parameters

Parameter Description Example Flags
SQLref The reference number returned by FM.SQL.Execute function. $SQLRef
Row The row you like to get. 1
FieldNames A list of field names for the JSON. "Model¶Names"
Flags The flags for the json creation.
Pass 1 to get all values as text.
Pass 2 to get all dates, times and timestamps in SQL format.
1+2 Optional

Result

Returns JSON text or error.

Description

Returns a row as JSON object.
You provide list of field names, which should be in same order as fields in SQL result.
Optionally we can return SQL dates, times and timestamps as SQL format.
Containers are returned as Base64 encoded data.

See FM.SQL.XMLRecord for the same as XML.

Examples

Query JSON record:

# run query to get some data
Set Variable [ $sql ; Value: MBS( "FM.SQL.Execute"; ""; "SELECT \"First\", \"Last\", Company, \"Photo Container\" FROM Contacts") ]
# query data
Set Variable [ $json ; Value: MBS( "FM.SQL.JSONRecord"; $sql; 0; "First¶Last¶Company¶Photo"; 2) ]
# store result
Set Field [ Contacts::Output ; $xml ]
# free memory
Set Variable [ $xml ; Value: MBS( "FM.SQL.Release"; $sql) ]

Query record as JSON:

Let ( [
fields = MBS( "FM.QueryFieldsForTableName"; "Contacts");
Records = MBS( "FM.SQL.Execute"; ""; "SELECT \"" & substitute(fields; ¶; "\", \"") & "\" FROM \"Contacts\" WHERE \"First\" = ?"; "Joe");

json = MBS( "FM.SQL.JSONRecord"; Records; 0; fields);
r = MBS( "FM.SQL.Release"; Records )]
; json )

See also

Blog Entries

FileMaker Magazin

Release notes

Created 4th March 2018, last changed 30th June 2020


FM.SQL.JSONColumn   -   FM.SQL.JSONRecords

Feedback: Report problem or ask question.




Links
MBS Xojo PDF Plugins

Start Chat