JObject对json的操作
发布日期:2021-11-09 22:51:14 浏览次数:35 分类:技术文章

本文共 908 字,大约阅读时间需要 3 分钟。

一,需去程序集添加using Newtonsoft.Json.Linq;引用

 

using System;using System.Collections.Generic;using System.Linq;using System.Web;using System.Web.UI;using System.Web.UI.WebControls;using System.Linq;using Newtonsoft.Json.Linq;using Newtonsoft.Json;using System.IO;using System.Net;public partial class _Default : System.Web.UI.Page{    protected void Page_Load(object sender, EventArgs e)    {        string str = "{'a':'aaa','b':'bbb','c':'ccc'}";        JObject jo = JObject.Parse(str);        if (jo.Property("a") == null || jo.Property("3").ToString() == "")        {            Label1.Text = "键值key不存在!";        }        IEnumerable
properties = jo.Properties(); foreach (JProperty item in properties) { Label2.Text += item.Name + ":" + item.Value; } Label3.Text = jo.Value
("a"); }}

 

转载于:https://www.cnblogs.com/May-day/p/5821975.html

转载地址:https://blog.csdn.net/dcujcivw769565/article/details/101260422 如侵犯您的版权,请留言回复原文章的地址,我们会给您删除此文章,给您带来不便请您谅解!

上一篇:MVC运行机制
下一篇:MVC中的Startup.Auth.cs、BundleConfig.cs、FilterConfig.cs和RouteConfig.cs

发表评论

最新留言

留言是一种美德,欢迎回访!
[***.207.175.100]2024年04月03日 01时43分23秒