"For developers", "Server scripts", "Functions description", "JSON", "JSONArraySetString".
Changing a specified text element of a JSON array by index. The index begins from 0.
function JSONArraySetString(var sJSON: string; iIdx: integer; sValue: string): integer;
Parameter |
Type |
Value |
---|---|---|
var sJSON |
string |
JSON object as a text string; |
iIdx |
integer |
index of the required array element; |
sValue |
string |
the contents of the array element. |
-1 |
JSON parsing error; |
-2 |
invalid index or type of the array element; |
0 |
function done successfully. |
var
JSONArr, s: string;
begin
JSONArr := '["first", "second", "third"]';
mLogScript(JSONArr, 'before');
JSONArrayGetString(JSONArr, 1, s);
JSONArraySetString(JSONArr, 1, UpperCase(s));
mLogScript(JSONArr, 'after');
end.
[13:46:05] (Log "JSONArraySetString"): [before] ["first", "second", "third"]
[13:46:05] (Log "JSONArraySetString"): [after] ["first","SECOND","third"]
[13:46:05] (Run "JSONArraySetString"): Script operation time: 6 ms
[13:46:05] (Run "JSONArraySetString"): Script done successfully.