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.5
10.0
10.1
10.2
10.3
10.4
10.5
11.0
11.1
11.2
Statistic
FMM
Blog
Parses JSON text and return reference number.
Component | Version | macOS | Windows | Linux | Server | iOS SDK |
JSON | 6.0 | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes |
Parameter | Description | Example |
---|---|---|
JSON | The JSON text to parse. | "[1,2,3]" |
Returns reference number or error.
Parse an array:
# parse some json
$ref = MBS( "JSON.Parse"; "[1,2,3]" )
# query array size:
MBS( "JSON.GetArraySize"; $ref)
# free memory
MBS( "JSON.Release"; $ref)
Parse some JSON, display it formatted and release:
Set Variable [$json; Value:MBS( "JSON.Parse"; "{\"Hello\": \"World\"}" )]
Show Custom Dialog [$json; MBS("JSON.Format"; $json)]
Set Variable [$r; Value:MBS( "JSON.Release"; $json)]
Query IP via ipinfo.io:
Go to Layout [“Table”]
New Record/Request
#Start new session
Set Variable [$curl; Value:MBS("CURL.New")]
#Set URL to load (HTTP, HTTPS, FTP, FTPS, SFTP, etc.)
Set Variable [$result; Value:MBS("CURL.SetOptionURL"; $curl; "http://ipinfo.io")]
#RUN now
Set Variable [$result; Value:MBS("CURL.Perform"; $curl)]
#Check result
Set Field [Table::DebugLog; MBS("CURL.GetDebugAsText"; $curl)]
Set Field [Table::Result; MBS("CURL.GetResultAsText"; $curl; "UTF8")]
If [$result = "OK"]
#Check HTTP error code
Set Variable [$response; Value:MBS("CURL.GetResponseCode"; $curl)]
If [$response = 200]
#Query values from JSON
Set Variable [$json; Value:MBS( "JSON.Parse"; Table::Result )]
Set Field [Table::IP; MBS("JSON.GetPathItem"; $json; "ip"; 1)]
Set Field [Table::Hostname; MBS("JSON.GetPathItem"; $json; "hostname"; 1)]
Set Field [Table::City; MBS("JSON.GetPathItem"; $json; "city"; 1)]
Set Field [Table::Region; MBS("JSON.GetPathItem"; $json; "region"; 1)]
Set Field [Table::Country; MBS("JSON.GetPathItem"; $json; "country"; 1)]
Set Field [Table::Location; MBS("JSON.GetPathItem"; $json; "loc"; 1)]
Set Field [Table::Company or Provider; MBS("JSON.GetPathItem"; $json; "org"; 1)]
Set Variable [$r; Value:MBS( "JSON.Release"; $json )]
End If
End If
#Cleanup
Set Variable [$result; Value:MBS("CURL.Release"; $curl)]
Commit Records/Requests [No dialog]
Created 5th January 2016, last changed 19th April 2020
Feedback: Report problem or ask question.