Components | All | New | MacOS | Windows | Linux | iOS | ||||
Examples | Mac & Win | Server | Client | Guides | Statistic | FMM | Blog | Deprecated | Old |
JSON.GetStringValue
Queries string value of the JSON node.
Component | Version | macOS | Windows | Linux | Server | iOS SDK |
JSON | 2.7 | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes |
Parameters
Parameter | Description | Example |
---|---|---|
json | A JSON text or reference. | "[1,2,3]" |
Result
Returns text.
Description
Queries string value of the JSON node.Examples
Get string value:
MBS( "JSON.GetStringValue"; "\"Hello\rjust a test\"" )
Example result:
Hello
just a test
Extract error details from JSON:
# JSON in field:
#{
# "error": {
# "message": "Your card's expiration year is invalid.",
# "type": "card_error",
# "param": "exp_year",
# "code": "invalid_expiry_year"
# }
#}
#get it in variable
Set Variable [$json; Value:test::input]
#pick error node
Set Variable [$error; Value:MBS("JSON.GetObjectItem"; $json; "error")]
If [$error = ""]
Show Custom Dialog ["No error"; "No error node in the JSON."]
Else
#get message node
Set Variable [$message; Value:MBS("JSON.GetObjectItem"; $error; "message")]
#decode text
Set Variable [$messageText; Value:MBS("JSON.GetStringValue"; $message)]
#get code node
Set Variable [$code; Value:MBS("JSON.GetObjectItem"; $error; "code")]
#decode text
Set Variable [$codeText; Value:MBS("JSON.GetStringValue"; $code)]
#show result
Show Custom Dialog ["Got error"; "Message: " & $messageText & ¶ & "Code: " & $codeText]
End If
Decode string with unicode text:
MBS( "JSON.GetStringValue"; "\"Hello \u00e4\"" )
Decode the escape unicode sequence:
MBS( "JSON.GetStringValue"; "\"\uD83C\uDF4E\"")
Example result: 🍎
See also
Release notes
- Version 13.4
- Changed JSON.GetStringValue, JSON.GetBooleanValue, JSON.GetDoubleValue, JSON.GetIntegerValue and JSON.GetValue to return empty result if called with empty value.
- Version 12.5
- Fixed problem in JSON.GetStringValue crashing for invalid JSON.
Example Databases
Blog Entries
This function checks for a license.
Created 18th August 2014, last changed 31st January 2023