zoukankan      html  css  js  c++  java
  • 解析json并存入对象,然后逐行打印对象的属性

    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Linq;
    using System.Text;
    using System.Threading.Tasks;
    using System.Windows.Forms;
    using Newtonsoft.Json;
    using System.IO;
    using Newtonsoft.Json.Linq; 
    
    namespace test解析json
    {
        public partial class Form1 : Form
        {
            public Form1()
            {
                InitializeComponent();
            }
    
            private void button1_Click(object sender, EventArgs e)
            {
                Album_List a = new Album_List();
                string s2 = "[{'album_scope':1,'picture_num':'1982','album_sign':'1190af2198dfd63dacc4f14f4d08016a103f0383','album_name':'u538bu529bu6d4bu8bd5u76f8u518c2','is_secret':0},{'album_scope':0,'picture_num':'1982','album_sign':'4b44e2e6547497365a062dad521739bebcfd4754','album_name':'u538bu529bu6d4bu8bd5u76f8u518c','is_secret':0},{'album_scope':0,'picture_num':'3','album_sign':'1190af2198dfd63dad88f24f4d08016a103f0377','album_name':'2014-03-05','is_secret':0},{'album_scope':1,'picture_num':'6','album_sign':'7d6ec7be7f93282e00239d5e3ba9d7f301860869','album_name':'testu76f8u518c04','is_secret':0},{'album_scope':1,'picture_num':'6','album_sign':'a7027a36a2d6c3d0998f3e18edff7f93292e1369','album_name':'testu76f8u518c03','is_secret':0},{'album_scope':1,'picture_num':'100','album_sign':'dad60f8a6edd8f3d741bee2d8068e8d928abf06a','album_name':'testu76f8u518c02','is_secret':0},{'album_scope':1,'picture_num':'50','album_sign':'392b1a684a86c51227e42e047ff9ba6351771c72','album_name':'testu76f8u518c01','is_secret':0}]";
    List<Album_List> _list = JsonConvert.DeserializeObject<List<Album_List>>(s2);
    foreach (Album_List aa in _list) { foreach (System.Reflection.PropertyInfo Pppp in aa.GetType().GetProperties()) { this.textBox1.Text += Pppp.Name; this.textBox1.Text += ":"; this.textBox1.Text += aa.GetType().GetProperty(Pppp.Name).GetValue(aa, null); this.textBox1.Text += " "; } } ; } } public class Album_List { public string album_scope { get; set; } public string picture_num { get; set; } public string album_sign { get; set; } public string album_name { get; set; } public string is_secret { get; set; } } }
  • 相关阅读:
    WinDbg 查看静态变量
    PLSQL 安装说明
    WinDbg设置托管进程断点
    SQL Server 数据库备份策略,第一周运行失败的原因
    Eclipse开发C/C++ 安装配置图文详解
    C 语言静态链表实现
    C语言结构体,C语言结构体指针,java对象引用,传值,传地址,传引用
    C Primer Plus 收官二叉搜索树实现
    GDB 调试C程序
    C语言 结构体存储空间分配
  • 原文地址:https://www.cnblogs.com/ashamp/p/3585045.html
Copyright © 2011-2022 走看看