The JsonFromString function converts a string into a JSON object.
string @JsonFromString(string jsonContent);
Parameters
string jsonContent : JSON string to parse
Return Values
The ID of the JSON object on success (the format is "JsonStruct_{number}")
Return an empty string on failure
Example 1)
Read a file saved in JSON format and load it into the buf
filepath =
"C:\\AutoBase\\Project\\ApiClientTest\\RESTAPIClient\\SolarEnergy_log.txt";
size =
@FileGetSize(filepath);
handle = @FileOpen(filepath, "r"); //Open as
read-only
if(handle != 0)
{
@FileRead(handle, jsonString, size, 1);
// Read in UTF-8 format
@FileClose(handle);
}
string
jsonObjectId = @JsonFromString(jsonString);
// Using Transformed Objects
string name =
@JsonGetValue(jsonObjectId, "name");
Version information
Supported Version: 10.3.6.25 or later
Related Helps)
JsonTemplateReplacePlaceholder