尝试使用Json.Net

时间:2017-01-22 19:33:09

标签: c# json dictionary serialization json.net

我试图用Json.net序列化int数组的嵌套字典(<int[], <int[], int>>),但是当我通过序列化程序运行它时:

string dumpFile = JsonConvert.SerializeObject(chordChain, Formatting.Indented);

我明白了:

{
  "Int32[] Array": {
    "Int32[] Array": 10,
    "Int32[] Array": 100,
    "Int32[] Array": 50
  },
  "Int32[] Array": {
    "Int32[] Array": 50,
    "Int32[] Array": 10,
    "Int32[] Array": 100
  },
  "Int32[] Array": {
    "Int32[] Array": 100,
    "Int32[] Array": 50,
    "Int32[] Array": 10
  }
}

我期待的是:

{
  "[0, 4, 7]": {
    "[0, 4, 7]": 10,
    "[5, 9, 0]": 100,
    "[7, 11, 2]": 50
  },
  "[5, 9, 0]": {
    "[0, 4, 7]": 50,
    "[5, 9, 0]": 10,
    "[7, 11, 2]": 100
  },
  "[7, 11, 2]": {
    "[0, 4, 7]": 100,
    "[5, 9, 0]": 50,
    "[7, 11, 2]": 10
  }
}

Json.net应该序列化吗?如果是这样,我需要做什么?

感谢。

0 个答案:

没有答案