Parsing object to array/Getting name of an object attribute

Hello everyone, I had an idea to try to make a tool for saving the state of a running program on processing, which could be applied by adding just a couple of lines, I would call it “quick save”. The problem is that in any code there are different objects (containing data variables) that we want to store.
I can’t just take an object and transform it into a JSONObject (to save it as a .json file) and vice versa, as it does in JavaScript.
Question: Is it possible to get the attributes of an object in the form of a list of names and refer to an attribute of an object by name.
It might look like this:

class Like
  int id = 0; // 0
  String members = "mem e"; //1
  int Partition = 3; // 2
  boolean flag = fasle; // 3
  Like () {}
Like objectLike = new Like ();
String temp = functionTakesNameOfObjectAttribute (objectLike, 2); // fuction result "Partition", because it is in second place in the class.
int countPartick = functionGetValueToObjectAttribute (objectLike, temp); // read the value of an object variable into a local variable
functionSetValueToObjectAttribute (objectLike, temp, countPartick+1); // value Partition becomes "4"

Is it generally possible to interact with objects in Processing more than is available in Processing itself?


Maybe Get functions / variables / classes from processing and user


Its awesome, anytime i check this opportunity. But I dont know, why this tread dont be in search results :thinking:
this looks like the solution I need, if this is it I will tag your message, thanks again!

1 Like

I think your idea is really cool

But I don’t know if it’s possible