下面的JSON如何生成C#类

youhaoxinqin2013 2015-02-28 04:33:47


{
"success": true,
"resultMessage": "",
"resultCode": null,
"result": {
"385620": [
{
"id": 4680760,
"skuId": 385620,
"path": "380/f8f1be5f-4e4e-439b-9fb4-d4ebf2dfb39d.jpg",
"created": "2011-07-26 16:54:25",
"modified": "2011-07-26 16:54:25",
"yn": 1,
"isPrimary": 0,
"orderSort": 0,
"position": null,
"type": null,
"features": null
},
{
"id": 4680759,
"skuId": 385620,
"path": "3150/f96166cb-8686-40fe-b8c7-14c82132940f.jpg",
"created": "2011-07-26 16:54:25",
"modified": "2011-07-26 16:54:25",
"yn": 1,
"isPrimary": 0,
"orderSort": 1,
"position": null,
"type": null,
"features": null
},
{
"id": 4680756,
"skuId": 385620,
"path": "1896/43e31383-d821-4cdf-b487-09df9e557783.jpg",
"created": "2011-07-26 16:54:25",
"modified": "2011-07-26 16:54:25",
"yn": 1,
"isPrimary": 1,
"orderSort": 2,
"position": null,
"type": null,
"features": null
},
{
"id": 4680758,
"skuId": 385620,
"path": "2872/fe2c8c2c-6fd0-4759-8b56-8c76049949b3.jpg",
"created": "2011-07-26 16:54:25",
"modified": "2011-07-26 16:54:25",
"yn": 1,
"isPrimary": 0,
"orderSort": 3,
"position": null,
"type": null,
"features": null
},
{
"id": 4680757,
"skuId": 385620,
"path": "2593/1b8a7654-7d3f-400f-9d39-d496152db839.jpg",
"created": "2011-07-26 16:54:25",
"modified": "2011-07-26 16:54:25",
"yn": 1,
"isPrimary": 0,
"orderSort": 4,
"position": null,
"type": null,
"features": null
}
],
"937433": [
{
"id": 4023269,
"skuId": 937433,
"path": "g13/M08/08/01/rBEhVFIbHb8IAAAAAAFmGihDzWIAACdugO9ws8AAWYy662.jpg",
"created": "2013-08-26 17:20:01",
"modified": "2014-07-24 19:51:54",
"yn": 1,
"isPrimary": 1,
"orderSort": 0,
"position": null,
"type": null,
"features": null
},
{
"id": 4023267,
"skuId": 937433,
"path": "g13/M08/08/01/rBEhUlIbHb8IAAAAAADxJRUowG4AACdugPFn48AAPE9061.jpg",
"created": "2013-08-26 17:20:01",
"modified": "2013-08-26 17:20:01",
"yn": 1,
"isPrimary": 0,
"orderSort": 1,
"position": null,
"type": null,
"features": null
},
{
"id": 4023268,
"skuId": 937433,
"path": "g13/M08/08/01/rBEhUlIbHcAIAAAAAAHc-V7em8kAACdugPogkcAAd0R400.jpg",
"created": "2013-08-26 17:20:01",
"modified": "2013-08-26 17:20:01",
"yn": 1,
"isPrimary": 0,
"orderSort": 2,
"position": null,
"type": null,
"features": null
},
{
"id": 4023266,
"skuId": 937433,
"path": "g13/M07/08/01/rBEhVFIbHcAIAAAAAAL_uibLmwIAACduwAUxlIAAv_S112.jpg",
"created": "2013-08-26 17:20:01",
"modified": "2013-08-26 17:20:01",
"yn": 1,
"isPrimary": 0,
"orderSort": 3,
"position": null,
"type": null,
"features": null
}
]
}
}

...全文
265 8 打赏 收藏 转发到动态 举报
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
king4323210 2015-03-02
  • 打赏
  • 举报
回复
4.0有方法可以直接调用
slwsss 2015-02-28
  • 打赏
  • 举报
回复
改下上面的

namespace Example
{
    public class Model
    {
        public int id;
        public int skuId;
        public string path;
        public string created;
        public string modified;
        public int yn;
        public int isPrimary;
        public int orderSort;
        public object position;
        public object type;
        public object features;
    }
    public class SampleResponse1
    {
        public bool success;
        public string resultMessage;
        public object resultCode;
        public Dictionary<string, Model[]> result;
    }
}
Hello World, 2015-02-28
  • 打赏
  • 举报
回复
上面的加多了个xxx,去掉后应该是:

// Generated by Xamasoft JSON Class Generator
// http://www.xamasoft.com/json-class-generator

using System;
using System.Collections.Generic;
using Newtonsoft.Json.Linq;

namespace Example
{
    public class 385620
    {
        public int id;
        public int skuId;
        public string path;
        public string created;
        public string modified;
        public int yn;
        public int isPrimary;
        public int orderSort;
        public object position;
        public object type;
        public object features;
    }

    public class 937433
    {
        public int id;
        public int skuId;
        public string path;
        public string created;
        public string modified;
        public int yn;
        public int isPrimary;
        public int orderSort;
        public object position;
        public object type;
        public object features;
    }

    public class Result
    {
        public 385620[] 385620;
        public 937433[] 937433;
    }

    public class SampleResponse1
    {
        public bool success;
        public string resultMessage;
        public object resultCode;
        public Result result;
    }
}
Hello World, 2015-02-28
  • 打赏
  • 举报
回复
参考:

// Generated by Xamasoft JSON Class Generator
// http://www.xamasoft.com/json-class-generator

using System;
using System.Collections.Generic;
using Newtonsoft.Json.Linq;

namespace Example
{

    public class 385620
    {
        public int id;
        public int skuId;
        public string path;
        public string created;
        public string modified;
        public int yn;
        public int isPrimary;
        public int orderSort;
        public object position;
        public object type;
        public object features;
    }

    public class 937433
    {
        public int id;
        public int skuId;
        public string path;
        public string created;
        public string modified;
        public int yn;
        public int isPrimary;
        public int orderSort;
        public object position;
        public object type;
        public object features;
    }

    public class Result
    {
        public 385620[] 385620;
        public 937433[] 937433;
    }

    public class Xxx
    {
        public bool success;
        public string resultMessage;
        public object resultCode;
        public Result result;
    }

    public class SampleResponse1
    {
        public Xxx xxx;
    }

}

Hello World, 2015-02-28
  • 打赏
  • 举报
回复
如果懒得动手可以用户JsonCSharpClassGenerator来生成
youhaoxinqin2013 2015-02-28
  • 打赏
  • 举报
回复
引用 1 楼 slwsss 的回复:
class + Dictionary
大神能给出代码吗?谢谢
slwsss 2015-02-28
  • 打赏
  • 举报
回复
class + Dictionary

87,907

社区成员

发帖
与我相关
我的任务
社区描述
Web 开发 JavaScript
社区管理员
  • JavaScript
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧