Hi all!

Need a little help here: I need to use a .json file instead of a SQL Database (for framework reasons). Itīs gonna be a highscore database for a mobile game and looks like so (example data):

Code:
{"Highscores":[
    {"Name":"Marina","Time":"2:30","Points":1320},
    {"Name":"Stefano","Time":"2:32","Points":1319},
    {"Name":"Christine","Time":"1:30","Points":2435},
    {"Name":"Michael","Time":"3:42","Points":878},
    {"Name":"Myriam","Time":"1:55","Points":2590},
    ]}
Now I need to READ and WRITE into that "database" but have no clue how to do this. I managed to insert a row like this:

Code:
function setHighscore(newtime, newhighscore, newname) {

        //open highscore.json
        var dh = Stream.openFile(this._datei,"r");

        var jsonobject=parseData(dh);//h.toString();
        dh.close;

       //set new values
        jsonobject["Highscores"][5]["Time"]=newtime;
        jsonobject["Highscores"][5]["Points"]=newhighscore;
        jsonobject["Highscores"][5]["Name"]=newname;

       
        var dh2 = Stream.openFile(this._datei,"w+");
        dh2.printf("%v",jsonobject);
        dh2.close();
    }
however this only works if I have an empty data-record on position "5" which will then be filled. But I want it to append whatever new values to the END of the array. since the highscore database will be growing it should determine the last position and insert the new values accordingly.

Next thing, I also need to display the "Top Ten" of this database on a seperate screen. Iīm a noob so please bear with me. This is what I tried to retrieve data:

Code:
function getHighscore(nr) {
        
        //TODO: Exceptions
        var dh = Stream.openFile(this._datei,"r");
        //Parse JSON File

        var data = parseData(dh);
        //return data
        console << data["Highscores"][nr-1]["Time"];
        //dh.print(text);
        dh.close;
    }
this works fine for just one parameter (in this case Time) but as soon as I add the other ones (name, points) it returns "undefined". What am I doing wrong here?

btw Iīm using Moscrif framework which is a JavaScript derivate...but very similar to it.

many thanks in advance