dimanche 10 juillet 2016

Assign a variable to JSON "value" object (i.e in 'Name-VALUE' pairs)


I have a Python program that returns the Room Temperature value in a variable (say temp). Now I have to assign this variable to a JSON as input. My JSON will be like:

{
  "inputs": [
    {
      "name": "Temperature",
      "value": "54.5"
    }
  ]
}

Here, instead of assigning 54.5 in the "value" field, I want to assign temp, so that it won't be a constant.With this i'm trying to make REST calls to a server which supports JSON inputs. The REST calls update the table with the current temperature value. So it shouldn't be a constant and it should be the value from the variable temp.


Aucun commentaire:

Enregistrer un commentaire