如何在 Azure 函数中解析 Json [英] How can I Parse Json in a Azure Function

查看:15
本文介绍了如何在 Azure 函数中解析 Json的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在这个函数中创建了一个 Azure 函数我调用了一个返回 JSON 的 API.我想将此 JSON 解析为一个对象,以便我可以在函数中使用它.我不能不使用 Newton.JSON,因为函数看起来不知道这个.如何解析 JSON?"

"I have create a 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 not use Newton.JSON as the function seems not to know this. How can I parse the JSON?"

推荐答案

在 Azure 函数中,您首先需要添加对 NewtonSoft.JSON 的引用.您可以通过Newtonsoft.Json"执行此操作.不要忘记引号!!!

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!!!

你可以通过 newtonsoft 使用正常的序列化:

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);

这篇关于如何在 Azure 函数中解析 Json的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆