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
JSON.Import
Imports JSON and creates tables, fields and records.
Component | Version | macOS | Windows | Linux | Server | FileMaker iOS SDK |
JSON | 5.4 | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes |
Parameters
Parameter | Description | Example | Flags |
---|---|---|---|
JSON | The JSON data to import. Please pass text, not reference numbers. |
||
InsertFileName | The file name of where the insert table is inside. Can be empty. | Get(FileName) | |
TableNamePrefix | The prefix to put in front of all tables. | "Import" | Optional |
Result
Returns number or error.
Description
Imports JSON and creates tables, fields and records.This function can import any JSON into FileMaker tables with all fields and attributes.
Returns number of records to be added. This function prefers the import and runs it later at idle time. In a script please call JSON.Import and then loop and do script pauses. Then use JSON.Import.Status to check regularly for updates. When you get back Finished as status, the script can continue with other work.
If you have a JSON file you need to import regularly into FileMaker and you have no XSLT to transform it for FileMaker, you can use this plugin function. On the first run, it creates for a sample JSON file the required tables and fields. Then you can define any layout or script to process values, e.g. copy into your tables. On further runs the plugin may add more fields (if newer JSON file has more fields) and import newer records.
All tables have three default fields. _RecordUUID is an unique identifier for the record. _ParentRecordUUID provides a link to the record one level higher in the JSON. This can be used to find child/parent records. The _CreationTimeStamp is the creation date, so you can distinguish different imports.
As a lot of records with a lot of data is imported and you may not need everything, you may want to put the imports in an extra FileMaker file. You decide if you clear tables before import or you want to keep history of all imports.
If the JSON has errors like a missing < in the JSON, you get an error. If you switch on IgnoreError parameter, the plugin reads everything until the error is reached which may give less records than possible.
This function works at idle time which is currently (FM 14) not supported on server.
Requires FileMaker 12 or newer.
On Server, please add a loop calling JSON.Import.Work to make progress.
See also XML.Import.SetBaseFields and XML.Import.SetExtraField.
Examples
Imports test.json into FileMaker:
Set Variable [$text; Value:MBS("Text.ReadTextFile"; "/Users/cs/Desktop/test.json"; "UTF-8")]
Set Variable [$r; Value:MBS("JSON.Import"; $text; ""; "")]
Set Variable [$text; Value:""]
If [MBS("IsError") = 0]
Set Variable [$total; Value:MBS("JSON.Import.Total")]
Loop
Set Variable [$todo; Value:MBS("JSON.Import.Todo")]
Pause/Resume Script [Duration (seconds): 1]
Set Variable [$s; Value:MBS("JSON.Import.Status")]
Exit Loop If [$s ≠ "Working"]
End Loop
Show Custom Dialog ["JSON Import"; $r & " " & $s]
End If
Import script with progress bar for importing JSON with Windows ANSI encoding:
Go to Layout [“JSON Import” (Import2Row)]
Delete All Records [No dialog]
Set Variable [$r; Value:MBS("ProgressDialog.SetBottomText"; "")]
Set Variable [$r; Value:MBS("ProgressDialog.SetTopText"; "Importiere JSON")]
Set Variable [$r; Value:MBS("ProgressDialog.SetTitle"; "Import...")]
Set Variable [$r; Value:MBS("ProgressDialog.SetButtonCaption"; "Abbrechen")]
Set Variable [$r; Value:MBS("ProgressDialog.SetProgress"; -1)]
Set Variable [$r; Value:MBS("ProgressDialog.Show")]
Pause/Resume Script [Duration (seconds): ,1]
Set Variable [$text; Value:MBS("Text.ReadTextFile"; "/Users/cs/Desktop/test.JSON"; "Windows")]
Set Variable [$r; Value:MBS("JSON.Import"; $text; ""; "Import2")]
Set Variable [$text; Value:""]
If [MBS("IsError") = 0]
Set Variable [$total; Value:MBS("JSON.Import.Total")]
Loop
Set Variable [$todo; Value:MBS("JSON.Import.Todo")]
Set Variable [$r; Value:MBS("ProgressDialog.SetProgress"; ($total - $todo) * 100 / $total)]
Set Variable [$r; Value:MBS("ProgressDialog.SetBottomText"; "Schritt " & ($total - $todo) & " von " & $total)]
Pause/Resume Script [Duration (seconds): 1]
Set Variable [$s; Value:MBS("JSON.Import.Status")]
Exit Loop If [$s ≠ "Working"]
If [MBS("ProgressDialog.GetCancel") = 1]
Set Variable [$r; Value:MBS("ProgressDialog.Hide")]
Set Variable [$r; Value:MBS("JSON.Import.Cancel")]
Exit Script []
End If
End Loop
Set Variable [$r; Value:MBS("ProgressDialog.Hide")]
Show Custom Dialog ["JSON Import"; $r & " " & $s]
End If
Set Variable [$r; Value:MBS("ProgressDialog.Hide")]
See also
- JSON.Import.Todo
- JSON.Import.Total
- ProgressDialog.GetCancel
- ProgressDialog.SetBottomText
- ProgressDialog.SetButtonCaption
- ProgressDialog.SetProgress
- ProgressDialog.Show
- Text.ReadTextFile
- XML.Import
- XML.Import.SetBaseFields
Example Databases
Blog Entries
- FileMaker 19.2 and the new fmplugin extended privilege
- With JSON in excellent form
- MBS FileMaker Plugin 5.4 for OS X/Windows
- MBS FileMaker Plugin, version 5.4pr4
FileMaker Magazin
Release notes
- Version 9.3
Created 26th October 2015, last changed 29th February 2020
JSON.GetValue - JSON.Import.Cancel
Feedback: Report problem or ask question.

Links
MBS FileMaker Plugins