zoukankan      html  css  js  c++  java
  • A sample way to convert json to object.

    Hi, I just create a sample for you. And it works under a sample test.
    Don`t remember to add
    using Newtonsoft.Json;

    public class JsonObjects
    {
    public authObject authObject;
    public billObj billObj;
    }
    
    public class authObject {
    public string userName;
    public string password;
    public string baladyCode;
    public string amanaCode;
    }
    
    public class billObj
    {
    public string billNumber;
    public string billCreationDate;
    public List<billDetails> billDetails;
    //public billDetail[] billDetails;
    }
    
    public class billDetails
    {
    public int depId;
    public int billValue;
    }
    string json =
    @"{
    authObject:{
    userName:7070,
    password:123,
    baladyCode:07,
    amanaCode:061
    },
    billObj:{
    billNumber:'0611138000302',
    billCreationDate:'07-01-1438',
    billDetails:
    [{depId:11006,billValue:1}]
    }
    }";
    public Form1()
    {
    InitializeComponent();
    JsonObjects objs = JsonConvert.DeserializeObject<JsonObjects>(json);
    }
    
     
    

      

    Love it, and you live without it
  • 相关阅读:
    K8s(2)-部署应用
    Docker-常用命令(7)
    Docker-堆栈stack(6)
    Docker-集群swarm(5)
    Docker-服务(4)
    Docker的概念术语(2)
    k8s(1)-使用kubeadm安装Kubernetes
    Celery-分布式任务队列
    使用Python管理压缩包
    jQuery基础
  • 原文地址:https://www.cnblogs.com/tomclock/p/6932213.html
Copyright © 2011-2022 走看看