使用数组对象将JSON转换为c#类

时间:2018-12-20 20:27:20

标签: c# json json.net

我有一个要转换为C#类的JSON对象。谁能指出我正确的方向?您如何将标记部分转换为C#类,因为标记具有字符串和数组。我在下面包括了JSON返回值以及我的类。有帮助或指示吗?

谢谢!

JSON:

{
 "markers": {
  "/New Quota (1)/two": {
   "limit": 50,
   "pending": 0,
   "oq": 0,
   "complete": 0
  },
  "/New Quota/AoAos/bo8Oi": {
   "limit": 20,
   "pending": 0,
   "oq": 0,
   "complete": 0
  },
  "/New Quota (1)/one": {
   "limit": 50,
   "pending": 0,
   "oq": 0,
   "complete": 0
  }
 },
 "priority": {
  "/New Quota (1)/one": 2
 },
 "plus": [
  "four",
  "five",
  "three",
  "two",
  "one"
 ],
 "sheets": {
  "New Quota (1)": [
   {
    "cellCount": 1,
    "tableTotal": 250,
    "tableIndex": 0
    "cells": [
     {
      "marker": "/New Quota (1)/one",
      "components": [
       "one"
      ]
     },
     {
      "marker": "/New Quota (1)/two",
      "components": [
       "two"
      ]
     }
    ]}]
 },
 "stopped": {
  "/New Quota/AoAos/s9oVa": "erwin on 02/24/2015 12:48"
 },
 "defines": {
  "XiiZn": {
   "cond": "(q1.r6)",
   "description": "55-64"
  },
  "LvmQy": {
   "cond": "(q1.r2)",
   "description": "18-24"
  }
 }
}    




public class RootObject
{

    public Sheet sheets { get; set; }
    public Marker marker { get; set; }

}

public class Marker
{

    public Dictionary<string,MarkerAttribute> markerAttribute { get; set; }
}

public class MarkerAttribute
{
    public int limit { get; set; }
    public int oq { get; set; }
    public int pending { get; set; }
    public int complete { get; set; }
}

public class Sheet
{
    public SheetAttribute sheetAttribute { get; set; }

}

public class SheetAttribute
{
    public int cellCount { get; set; }
    public int tableTotal { get; set; }
    public int tableIndex { get; set; }
    public string description { get; set; }
    public List<SheetCells> cells { get; set; }
}

public class SheetCells
{
    public string marker { get; set; }
    public List<string> component { get; set; }
}

0 个答案:

没有答案