zoukankan      html  css  js  c++  java
  • JObject对json的操作

    一,需去程序集添加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<JProperty> properties = jo.Properties();
            foreach (JProperty item in properties)
            {
                Label2.Text += item.Name + ":" + item.Value;
            }
    
            Label3.Text = jo.Value<string>("a");
        }
    }
  • 相关阅读:
    安装pgsql
    ln软连接
    vsftp上传失败
    redis配置systemctl
    jmeter 录制排除模式
    数据库基本操作
    按日期排序
    angularjs的cache
    angularjs路由传递参数
    angularjs路由相关知识
  • 原文地址:https://www.cnblogs.com/May-day/p/5821975.html
Copyright © 2011-2022 走看看