jsonazureazure-functions

How can I Parse Json in a Azure Function


I have created an Azure Function. In this function I call an API that returns JSON. I want to parse this JSON to an object so I can use it in the function. I cannot use Newton.JSON as the function seems not to know this. How can I parse the JSON?


Solution

  • In the Azure Function your first you need to add a reference to NewtonSoft.JSON. You can do this via "Newtonsoft.Json". Do not forget the quotes!!!

    Than you can use the normal serialization via newtonsoft:

    var response = await client.GetAsync("<url>");
    var json = await response.Content.ReadAsStringAsync();
    var o= JsonConvert.DeserializeObject<"Type">(json);