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:
12.1
12.2
12.3
12.4
12.5
13.0
13.1
13.2
13.3
13.4
Statistic
FMM
Blog
Imports JSON and creates tables, fields and records.
Component | Version | macOS | Windows | Linux | Server | iOS SDK |
JSON | 5.4 | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes |
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 |
RootTableName | Available in MBS FileMaker Plugin 12.2 or newer. The default root table name. Default is "json". |
Optional | |
Flags | Available in MBS FileMaker Plugin 12.3 or newer. Sum of flags. Add 128 to skip table creation. Add 256 to skip field creation. |
0 | Optional |
Returns number or error.
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")]
This function checks for a license.
Created 26th October 2015, last changed 11st March 2023