Reputation: 37
I am trying to load time series data from a JSON file to Azure Functions using req.get_json()
in Python and I would like the function to return a JSON file after some simple mathematical operations.
My JSON file looks like:
{ "Timestamp":{"0": "1500069600000","1": "1500073200000"}, "Data":{"0":"3","1":"4"}}
And I want to get a result in a JSON format which should be as follows (which is simply increasing the Data values by 1):
{ "Timestamp":{"0": "1500069600000","1": "1500073200000"}, "Data":{"0":"4","1":"5"}}
I would really appreciate it if anyone can help me with this, since this is my first time to work with Azure Functions.
Upvotes: 1
Views: 3368
Reputation: 23161
If you want to return JSON body in Azure function, please refer to the following code
async def main(req: func.HttpRequest) -> func.HttpResponse:
logging.info('Python HTTP trigger function processed a request.')
data =req.get_json()
for key in data["Data"].keys():
data["Data"][key]=4
return func.HttpResponse(json.dumps(data),
mimetype="application/json",)
Upvotes: 2