; JsonArrayInsert Example ; ----------------------- ; Requires Extended mode. q$=Chr(34) ; Double-quote character, for building JSON text ; The hero's quest log, in priority order quests=ParseJson("["+q+"find the key"+q+","+q+"open the vault"+q+"]") Print "Quest log: "+JsonStringify(quests,0) ; JsonArrayInsert copies the value in BEFORE the given index - ; an urgent quest jumps to the front (index 0) v=CreateJsonString("escape the dungeon!") JsonArrayInsert quests,0,v FreeJson v Print "Urgent quest inserted at 0:" Print " "+JsonStringify(quests,0) ; Inserting at the current count appends to the end v=CreateJsonString("spend the treasure") JsonArrayInsert quests,JsonCount(quests),v FreeJson v Print "Long-term quest inserted at count ("+(JsonCount(quests)-1)+"):" Print " "+JsonStringify(quests,0) FreeJson quests Print "" Print "Press any key to close the example" WaitKey End