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

查看:67
本文介绍了如何在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天全站免登陆