# How to access object by using it's name in string format?

**URL:** https://discourse.processing.org/t/how-to-access-object-by-using-its-name-in-string-format/38182
**Category:** Coding Questions
**Created:** [August 1, 2022, 4:53am UTC](https://discourse.processing.org/t/how-to-access-object-by-using-its-name-in-string-format/38182 "2022-08-01T04:53:59Z")
**Posts on this page:** 1
**Showing post:** 4

<div class="post-metadata">

### Author: ![GoToLoop](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/gotoloop/32/86_2.png) [@GoToLoop](https://discourse.processing.org/u/GoToLoop)
#### Post date: [August 1, 2022, 7:44am UTC](https://discourse.processing.org/t/how-to-access-object-by-using-its-name-in-string-format/38182/4 "2022-08-01T07:44:22Z")

</div>

If all the variables you need are of `int` type you can use an IntDict container to store them:

> **[IntDict / Reference](https://processing.org/reference/IntDict.html)**
>
> A simple class to use a String as a lookup for an int value. String "keys" are associated with integer values.

If they’re of mixed types you may try out a [JSONObject](https://processing.org/reference/JSONObject.html) like this post below:

> [@Save and recall variable in a file](https://discourse.processing.org/t/save-and-recall-variable-in-a-file/37968):
>
> Hi, I’m trying to save several variables to a file so I can reload them when the program opens. I manage to create a JSON file but I have to manually add the code, I would like to automate this by adding in an Array, the variables that I would like to save and recall. I managed to save my variables in a JSON file but I can’t extract these values ​​to reassign them to variables. Old code that is working : json = new JSONObject(); json.setInt("Mode", Mode); json.setInt("PortSe…

---

_[View the full topic](https://discourse.processing.org/t/how-to-access-object-by-using-its-name-in-string-format/38182)._
