使用不同的父节点名称反序列化JSon

时间:2014-08-26 09:20:43

标签: json deserialization

我正在尝试使用c#从Gitblit反序列化json响应,并且我将以下列格式恢复它

{
  "https://localhost/git/libraries/xmlapache.git": {
    "name": "libraries/xmlapache.git",
    "description": "apache xmlrpc client and server",
    "owner": "admin",
    "lastChange": "2010-01-28T22:12:06Z",
    "hasCommits": true,
    "showRemoteBranches": false,
    "useTickets": false,
    "useDocs": false,
    "accessRestriction": "VIEW",
    "isFrozen": false,
    "showReadme": false,
    "federationStrategy": "FEDERATE_THIS",
    "federationSets": [
      "libraries"
    ],
    "isFederated": false,
    "skipSizeCalculation": false,
    "skipSummaryMetrics": false,
    "size": "102 KB"
  },
  "https://localhost/git/libraries/smack.git": {
    "name": "libraries/smack.git",
    "description": "smack xmpp client",
    "owner": "admin",
    "lastChange": "2009-01-28T18:38:14Z",
    "hasCommits": true,
    "showRemoteBranches": false,
    "useTickets": false,
    "useDocs": false,
    "accessRestriction": "VIEW",
    "isFrozen": false,
    "showReadme": false,
    "federationStrategy": "FEDERATE_THIS",
    "federationSets": [],
    "isFederated": false,
    "skipSizeCalculation": false,
    "skipSummaryMetrics": false,
    "size": "4.8 MB"
  }
}

我在创建DataContract时遇到了麻烦,因为父节点是从pull url命名的,可能是任何东西而不是标准名称。我只需要从它们下面反序列化“name”:,“description”:,“owner”:,“lastChange”。

那么有什么方法可以反映每个数据集,同时忽略所有父节点?

0 个答案:

没有答案