Change a variable name in runtime that will be saved in JSON

Hello everyone! I’ve had this idea for a while that I can’t find a suitable solution for, so I decided to ask here to see what y’all think.

In short, I have a program that has some variables like these:

  • string _line
  • string _emotion
  • string _talker

These variables are saved in a class called DialogueLine, and in the program the player can write them and save them in a json file. This process is done automatically, you just write the line, emotion and talker and press a button that generates the json.

However, I thought that it would be interesting to allow the user to modify the name of these variables. So, if they don’t want _emotion, they can change the name to _faceDescription, or anything.

How could I do that? Thank you in advance for your time.

I don’t understand the point of what you’re asking. Surely you need to know what field goes with what data in order to do anything constructive with it when you load the json? Unless you just mean there’s always exactly those 3 fields, and they can name them whatever they want and your program will adapt?