Is there any way to get the fields and the values into Java code. For example, I have the following JSON:
{
"name":"Example",
"description":"An example",
"process_1": {
"name":"My process-1",
"image":"Docker Image",
"command":["command", "file_name"],
"arguments":["--arg"]
},
"process_2": {
"name":"My process-2",
"image":"Docker Image",
"command":["command", "file_name"],
"arguments":["--arg"]
}
.
.
.
.
"process_n": {
"name":"My process-n",
"image":"Docker Image",
"command":["command", "file_name"],
"arguments":["--arg"]
}
}
Now I want to get all the keys as variables with their corresponding values in java. Note that the field names in JSON are not constant i.e., the JSON file is dynamically created with different field names every time. The name and description fields are constant as well as the fields inside the processes. But not the process fields.
For example, in Java it should look like:
String name = "Example"
String description = "An Example"
String process_1_name = "My process-1"
String process_2_command = ["command", "file_name"]
Also I don't know how can I store the cascading fields as in "process-1".