Define variable names to be used in a json dictionary

Issue

This Content is from Stack Overflow. Question asked by codecrazy46

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?



Solution

This question is not yet answered, be the first one who answer using the comment. Later the confirmed answer will be published as the solution.

This Question and Answer are collected from stackoverflow and tested by JTuto community, is licensed under the terms of CC BY-SA 2.5. - CC BY-SA 3.0. - CC BY-SA 4.0.

people found this article helpful. What about you?