JsonStringSetValue

 

The JsonStringSetValue function modifies the value directly from the JSON string to the JSONPath expression.

 

 int @JsonStringSetValue (string objectId, string jsonPath, object value);

 int @JsonStringSetValue (string objectId, string jsonPath, object value, string dataType);

 

Parameters

string objectId        : Target JSON object ID
string jsonPath    : JSONPath expression to set the value
object value         : a value to set
string dataType : The data type of the value, "string" when not filled
    "string": string
    "int", "long" : integer
    "float", "double", "decimal": real
    "bool" : boolean
    "datetime" : datetime
    "null" : null

  

Return Values

 1 : Success

0 : 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)

 

 

Example )

//Assume the JSON string below is the current value of the string variable jsonString
{
    "person": {
        "name": "John",
        "age": 20
    }
}

 

string updatedJson = @JsonStringSetValue(jsonString, "$.person.name", "Patrick");
// Result : {"person":{"name":"Patrick","age":20}}

 

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