JsonArrayInsertNumber

value JsonArrayInsertNumber ( value jsonArray, value Index, value Value );

Rückgabewert

Rückgabewert

Beschreibung

TRUE / true / 1

Der numerische Wert von Value wurde erfolgreich eingefügt.

FALSE / false / 0

Der numerische Wert von Value konnte nicht eingefügt werden.

Parameter

jsonArray

Das gültige JSONARRAY-Objekt, in dem der numerische Wert von Value eingefügt werden soll.

Index

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

Value

Der numerische Wert, der eingefügt werden soll.

Bemerkungen

Fügt den numerischen Wert von Value 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, JsonArrayInsertObject, JsonArrayInsertString