JsonArrayInsertString

value JsonArrayInsertString ( value jsonArray, value Index, string strValue );

Rückgabewert

Rückgabewert

Beschreibung

TRUE / true / 1

Die Zeichenkette strValue wurde erfolgreich eingefügt.

FALSE / false / 0

Der Zeichenkette strValue konnte nicht eingefügt werden.

Parameter

jsonArray

Das gültige JSONARRAY-Objekt, in dem die Zeichenkette strValue eingefügt werden soll.

Index

Die Position im JSONARRAY-Objekt jsonArray an der die Zeichenkette strValue eingefügt werden soll. Für das erste JSONARRAY-Element gilt: Index = 0.

strValue

Die Zeichenkette, die eingefügt werden soll.

Bemerkungen

Fügt die Zeichenkette strValue an der Position Index in das JSONARRAY-Objekt's jsonArray ein.

Beispiel

//Inhalt von "data.json":
//{
//  "Boolean": true,
//  "Number": 3.14,
//  "WithoutContent": null,
//  "String": "xyz",
//  "Array": [
//    1,
//    true,
//    null,
//    "abc"
//  ]
//}
value json;
if (!JsonCreateFromFile(json, "data.json"))
    return (false);
end
value jsonArray, insertedArray;
jsonArray = JsonGetArray(json, "Array");
insertedArray = JsonArrayInsertArray(jsonArray, 1);

JsonArrayAddNumber(insertedArray, 2);
JsonArrayAddNumber(insertedArray, 3);

string strJson;
strJson = JsonToString(json);
//Inhalt von strJson:
//{
//  "Boolean": true,
//  "Number": 3.14,
//  "WithoutContent": null,
//  "String": "xyz",
//  "Array": [
//    1,
//    [
//      2,
//      3
//    ],
//    true,
//    null,
//    "abc"
//  ]
//}
JsonArrayInsertBool(jsonArray, 2, false);
JsonArrayInsertNumber(jsonArray, 3, e);
JsonArrayInsertString(jsonArray, 4, "def");
JsonArrayInsertNull(jsonArray, 4);

strJson = JsonToString(json);
//Inhalt von strJson:
//{
//  "Boolean": true,
//  "Number": 3.14,
//  "WithoutContent": null,
//  "String": "xyz",
//  "Array": [
//    1,
//    [
//      2,
//      3
//    ],
//    false,
//    2.718282,
//    null,
//    "def",
//    true,
//    null,
//    "abc"
//  ]
//}JsonClose(json);
 

Die Json-Funktionen

Siehe auch JsonArrayInsertArray, JsonArrayInsertBool, JsonArrayInsertNull, JsonArrayInsertNumber, JsonArrayInsertObject