Define variable names to be used in a json dictionary

Viewed 48

I have a json file where I want to define some query and the variables to be used for the query result to be stored into. I also want to define the display format of these variables in the json.

For eg:

JSON:

{
  operations: [
    operation: {
        "var": "a",
        "value": "<some query>"
        "additional_query": {
          "exists": true
          "var": "b",
          "value": "<some other query>"
        }
        "display_format": {
          "exists": true
          "value": "a - (b%)"
        }
    },
    {

    }
  ]
}

I want to be able to run the query defined in the json after parsing the same with python and save it to the value provided in "var" in json and then display the results assigned to variables 'a' and 'b' in the format defined in the json. Is this even possible with python and if yes how can this be achieved?

EDIT 1:

Just to be a bit clear,

  1. Say from query 1 we get an output 36, I would like to store this in a variable called 'a' as "var" for query is 'a'.
  2. Say from query 2 we get an output 45, I would like to store this in a variable called 'b' as "var" for additional query is 'b'.
  3. The display format has the value - a - (b%). Hence the output should be: 36 - (45%)
0 Answers
Related