# Frogger High score

**URL:** https://discourse.processing.org/t/frogger-high-score/37427
**Category:** Beginners
**Created:** [June 9, 2022, 4:42pm UTC](https://discourse.processing.org/t/frogger-high-score/37427 "2022-06-09T16:42:13Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![king\_B99](https://avatars.discourse-cdn.com/v4/letter/k/258eb7/32.png) [@king\_B99](https://discourse.processing.org/u/king_B99)
#### Post date: [June 9, 2022, 4:42pm UTC](https://discourse.processing.org/t/frogger-high-score/37427/1 "2022-06-09T16:42:13Z")

</div>

So I am trying to make a high score system for my frogger game I am using JSONObjects but its a little confusing can anyone show an example or explain it.

Thanks.

> **[Reference](https://processing.org/reference/JSONObject.html)**
>
> A JSONObject stores JSON data with multiple name/value pairs. Values can be numeric, Strings, booleans, other JSONObjects or JSONArrays, or null. JSONObject a…

---

<div class="post-metadata">

### Author: ![mnse](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/mnse/32/16520_2.png) [@mnse](https://discourse.processing.org/u/mnse)
#### Post date: [June 9, 2022, 4:50pm UTC](https://discourse.processing.org/t/frogger-high-score/37427/2 "2022-06-09T16:50:33Z")

</div>

Hi @king_B99

Its quite easy … maybe you can have a look here first …  
[JSON Load and Save data](https://processing.org/examples/loadsavejson.html)  
It ahows you how to load/save/access your data.

If you’ve tried it and post your approach here we can check if there a issues…

Cheers  
— mnse

---

<div class="post-metadata">

### Author: ![Chrisir](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/chrisir/32/45_2.png) [@Chrisir](https://discourse.processing.org/u/Chrisir)
#### Post date: [June 9, 2022, 5:17pm UTC](https://discourse.processing.org/t/frogger-high-score/37427/3 "2022-06-09T17:17:17Z")

</div>

see [Reference / Processing.org](https://processing.org/reference/saveJSONArray_.html)

here

```auto

void setup() {

  size(700, 700); 

  JSONArray values;

  values = new JSONArray();

  String[] name = { "Ann", "Frank", "Will" };
  String[] score = { "102", "201", "23" };

  for (int i = 0; i < name.length; i++) {

    JSONObject animal = new JSONObject();

    animal.setInt("id", i);
    animal.setString("name", name[i]);
    animal.setString("score", score[i]);

    values.setJSONObject(i, animal);
  }

  saveJSONArray(values, "data/new.json");

  values = null;

  println("saved.");
}

void draw() {
  //
  background(0); 
  text("any key to load", 33, 33);
}

//------------------------------------------------------------------

void keyPressed() {

  println("load");

  JSONArray values=null;

  values = loadJSONArray(dataPath("")+"/new.json");

  for (int i = 0; i < values.size(); i++) {

    JSONObject HighScore = values.getJSONObject(i); 

    int id = HighScore.getInt("id");
    String name =HighScore.getString("name");
    String score = HighScore.getString("score");

    println(id + ", " + name + " has " + score);
  }
}

```

Obviously you have to apply this to your program where players have a score
