JsonStringGetValue

 

The JsonStringGetValue function looks up the value directly from the JSON string as a JSONPath expression.

 

string @JsonStringGetValue(string source, string jsonPath);

 

Parameters

string source     : Target JSON string

string jsonPath  : JSONPath expression to look up the value

 

Return Values

Returns the value corresponding to the path on success (if multiple values are queried, returns a comma-separated string)

Return an empty string on failure

 

Note. JSONPath Expression Examples
$.name                    : The "name" attribute of the top-level object
$.address.city         : The "city" property of the nested object
$.items[0]                : the first element of the array
$.items[*]                 : All array elements
$.. name                  : All "name" attributes in the object tree
$.items[?( @.price>10)]    : Array element that matches the condition (element whose price is greater than 10)/p>

  

 

Example )

//Assume the JSON string below is the current value of the string variable jsonString
{
"products": [
    {"id": 1, "name": "Laptop", "price": 1200000},
    {"id": 2, "name": "Monitor", "price": 350000},
    {"id": 3, "name": "Keyboard", "price": 120000}
    ]
}

// Extract values from direct strings
string secondProductName = @JsonStringGetValue(jsonString, "$.products[1].name");
// Result : "Monitor"

// Extract all prices in an array
string allPrices = @JsonStringGetValue(jsonString, "$.products[*].price");
// Result : "1200000,350000,120000"

 

 

Version information

Supported Version: 10.3.6.25 or later

 

Related Helps)

JsonStructNew

JsonAppend

JsonSet

JsonToString

JsonClear

JsonGet

JsonFromString

JsonSetValue

JsonGetValue

JsonClearAll

JsonStringGetValue

JsonStringSetValue

JsonTemplateLoad

JsonTemplateReplacePlaceholder

JsonTemplateReplaceDone

JsonTemplateReplaceMissing

JsonTemplateTagSet