json无法访问Newtonsoft.Json.Linq.JValue上的子值

时间:2017-12-03 09:03:09

标签: c# json linq

我是json逻辑的新手,我有一个复杂的json,我必须从url读取并使用c#绑定到数据网格。

我的json文件:

 {
"expand": "schema,names",
"startAt": 0,
"maxResults": 50,
"total": 6,
"issues": [{
    "expand": "operations,versionedRepresentations,editmeta,changelog,renderedFields",
    "id": "10502",
    "self": "https://pr.myproject.net/sd/rest/api/2/issue/10502",
    "key": "WO-60",
    "fields": {
        "customfield_10230": null,
        "fixVersions": [],
        "customfield_10231": null,
        "resolution": null,
        "customfield_10510": [],
        "customfield_10229": null,
        "lastViewed": null,
        "customfield_10220": null,
        "priority": null,
        "customfield_10100": null,
        "customfield_10101": null,
        "labels": [],           
        "timeestimate": null,
        "versions": [],
        "customfield_10219": null,
        "issuelinks": [],
        "assignee": {
            "self": "https://pr.myproject.net/sd/rest/api/2/user?username=crewManagerTest",
            "name": "crewManagerTest",
            "key": "crewmanagertest",
            "emailAddress": "crewManagerTest@crewManagerTest.com",
            "avatarUrls": {
                "48x48": "https://secure.myproject.com/avatar/208c23b0f1be06c82402c1548a463e3e?d=mm&s=48",
                "24x24": "https://secure.myproject.com/avatar/208c23b0f1be06c82402c1548a463e3e?d=mm&s=24"
            },
            "displayName": "crewManagerTest",
            "active": true,
            "timeZone": "Europe"
        },
        "status": {
            "self": "https://pr.myproject.net/sd/rest/api/2/status/10000",
            "description": "",
            "iconUrl": "https://pr.myproject.net/sd/images/icons/status_generic.gif",
            "name": "To Do",
            "id": "10000",
            "statusCategory": {
                "self": "https://pr.myproject.net/sd/rest/api/2/statuscategory/2",
                "id": 2,
                "key": "new",
                "colorName": "blue-gray",
                "name": "To Do"
            }
        },
        "components": [],
        "customfield_10296": "CF-38",           
        "customfield_10603": "10502",
        "aggregatetimeestimate": null,
        "customfield_10604": "0",
        "customfield_10606": "",
        "creator": {
            "self": "https://pr.myproject.net/sd/rest/api/2/user?username=atlas",
            "name": "atlas",
            "key": "atlas",
            "emailAddress": "me@myproject.com",
            "avatarUrls": {
                "48x48": "https://pr.myproject.net/sd/secure/useravatar?ownerId=atlas&avatarId=10609",
                "24x24": "https://pr.myproject.net/sd/secure/useravatar?size=small&ownerId=atlas&avatarId=10609"                    
            },
            "displayName": "JIRA user",
            "active": true,
            "timeZone": "Europe"
        },
        "customfield_10280": null,
        "subtasks": [],
        "reporter": {
            "self": "https://pr.myproject.net/sd/rest/api/2/user?username=atlas",
            "name": "atlas",
            "key": "atlas",
            "emailAddress": "me@myproject.com",
            "avatarUrls": {
                "48x48": "https://pr.myproject.net/sd/secure/useravatar?ownerId=atlas&avatarId=10609",
                "24x24": "https://pr.myproject.net/sd/secure/useravatar?size=small&ownerId=atlas&avatarId=10609"                    
            },
            "displayName": "JIRA user",
            "active": true,
            "timeZone": "Europe"
        },
        "customfield_10285": null,
        "customfield_10286": null,
        "aggregateprogress": {
            "progress": 0,
            "total": 0
        },
        "progress": {
            "progress": 0,
            "total": 0
        },
        "votes": {
            "self": "https://pr.myproject.net/sd/rest/api/2/issue/WO-60/votes",
            "votes": 0,
            "hasVoted": false
        },
        "issuetype": {
            "self": "https://pr.myproject.net/sd/rest/api/2/issuetype/10116",
            "id": "10116",
            "description": "",
            "iconUrl": "https://pr.myproject.net/sd/secure/viewavatar?size=xsmall&avatarId=10300&avatarType=issuetype",
            "name": "Survey",
            "subtask": false,
            "avatarId": 10300
        },
        "customfield_10270": null,
        "timespent": null,
        "customfield_10271": null,
        "customfield_10272": null,
        "customfield_10273": null,
        "project": {
            "self": "https://pr.myproject.net/sd/rest/api/2/project/10103",
            "id": "10103",
            "key": "WO",
            "name": "Field Service",
            "avatarUrls": {
                "48x48": "https://pr.myproject.net/sd/secure/projectavatar?avatarId=10324",
                "24x24": "https://pr.myproject.net/sd/secure/projectavatar?size=small&avatarId=10324"
            }
        },
        "customfield_10275": null,
        "aggregatetimespent": null,
        "resolutiondate": null,
        "workratio": -1,
        "watches": {
            "self": "https://pr.myproject.net/sd/rest/api/2/issue/WO-60/watchers",
            "watchCount": 1,
            "isWatching": false
        },
        "created": "2017-11-27T15:44:49.000+0200",
        "updated": "2017-11-27T15:44:50.000+0200",
        "timeoriginalestimate": null,
        "description": null,
        "summary": "Mobile Test",
        "customfield_10240": null,
        "customfield_10241": null,
        "customfield_10000": "com",
        "environment": null,
        "customfield_10238": null,
        "customfield_10513": [],
        "customfield_10514": [],
        "customfield_10516": [],
        "duedate": null,
        "customfield_10519": null
    }
},
{
    "expand": "operations,versionedRepresentations,editmeta,changelog,renderedFields",
    "id": "10166",
    "self": "https://pr.myproject.net/sd/rest/api/2/issue/10166",
    "key": "WO-24",
    "fields": {
        "customfield_10230": null,
        "fixVersions": [],
        "customfield_10231": null,
        "resolution": {
            "self": "https://pr.myproject.net/sd/rest/api/2/resolution/10100",
            "id": "10100",
            "description": "This issue was not approved.",
            "name": "Declined"
        },
        "customfield_10510": [],
        "customfield_10503": [],
        "customfield_10229": null,          
        "lastViewed": null,
        "customfield_10220": null,
        "priority": null,
        "customfield_10100": null,
        "customfield_10101": null,
        "labels": [],
        "timeestimate": null,
        "versions": [],
        "customfield_10219": null,
        "issuelinks": [],
        "assignee": {
            "self": "https://pr.myproject.net/sd/rest/api/2/user?username=crewManagerTest",
            "name": "crewManagerTest",
            "key": "crewmanagertest",
            "emailAddress": "crewManagerTest@crewManagerTest.com",
            "avatarUrls": {
                "48x48": "https://secure.myproject.com/avatar/208c23b0f1be06c82402c1548a463e3e?d=mm&s=48",
                "24x24": "https://secure.myproject.com/avatar/208c23b0f1be06c82402c1548a463e3e?d=mm&s=24"
            },
            "displayName": "crewManagerTest",
            "active": true,
            "timeZone": "Europe"
        },
        "status": {
            "self": "https://pr.myproject.net/sd/rest/api/2/status/10145",
            "description": "",
            "iconUrl": "https://pr.myproject.net/sd/images/icons/statuses/generic.png",
            "name": "Rejected",
            "id": "10145",
            "statusCategory": {
                "self": "https://pr.myproject.net/sd/rest/api/2/statuscategory/3",
                "id": 3,
                "key": "done",
                "colorName": "green",
                "name": "Done"
            }
        },
        "components": [],
        "customfield_10296": "CF-41",           
        "customfield_10603": null,
        "aggregatetimeestimate": null,
        "customfield_10604": "0",
        "customfield_10606": "",
        "creator": {
            "self": "https://pr.myproject.net/sd/rest/api/2/user?username=atlas",
            "name": "atlas",
            "key": "atlas",
            "emailAddress": "me@myproject.com",
            "avatarUrls": {
                "48x48": "https://pr.myproject.net/sd/secure/useravatar?ownerId=atlas&avatarId=10609",
                "24x24": "https://pr.myproject.net/sd/secure/useravatar?size=small&ownerId=atlas&avatarId=10609"
            },
            "displayName": "JIRA user",
            "active": true,
            "timeZone": "Europe"
        },
        "customfield_10280": null,
        "subtasks": [],
        "reporter": {
            "self": "https://pr.myproject.net/sd/rest/api/2/user?username=atlas",
            "name": "atlas",
            "key": "atlas",
            "emailAddress": "me@myproject.com",
            "avatarUrls": {
                "48x48": "https://pr.myproject.net/sd/secure/useravatar?ownerId=atlas&avatarId=10609",
                "24x24": "https://pr.myproject.net/sd/secure/useravatar?size=small&ownerId=atlas&avatarId=10609"
            },
            "displayName": "JIRA user",
            "active": true,
            "timeZone": "Europe"
        },
        "customfield_10285": null,
        "customfield_10286": null,
        "aggregateprogress": {
            "progress": 0,
            "total": 0
        },
        "progress": {
            "progress": 0,
            "total": 0
        },
        "votes": {
            "self": "https://pr.myproject.net/sd/rest/api/2/issue/WO-24/votes",
            "votes": 0,
            "hasVoted": false
        },
        "issuetype": {
            "self": "https://pr.myproject.net/sd/rest/api/2/issuetype/10116",
            "id": "10116",
            "description": "",
            "iconUrl": "https://pr.myproject.net/sd/secure/viewavatar?size=xsmall&avatarId=10300&avatarType=issuetype",
            "name": "Survey",
            "subtask": false,
            "avatarId": 10300
        },
        "customfield_10270": null,
        "timespent": null,
        "customfield_10271": null,
        "customfield_10272": null,
        "customfield_10273": null,
        "project": {
            "self": "https://pr.myproject.net/sd/rest/api/2/project/10103",
            "id": "10103",
            "key": "WO",
            "name": "Field Service",
            "avatarUrls": {
                "48x48": "https://pr.myproject.net/sd/secure/projectavatar?avatarId=10324",
                "24x24": "https://pr.myproject.net/sd/secure/projectavatar?size=small&avatarId=10324"
            }
        },
        "customfield_10275": null,
        "aggregatetimespent": null,
        "resolutiondate": "2017-07-02T15:05:20.000+0300",
        "workratio": -1,
        "watches": {
            "self": "https://pr.myproject.net/sd/rest/api/2/issue/WO-24/watchers",
            "watchCount": 1,
            "isWatching": false
        },
        "created": "2017-06-07T18:23:03.000+0300",
        "updated": "2017-07-02T15:05:20.000+0300",
        "timeoriginalestimate": null,
        "description": null,
        "summary": "Mobile Test 4",
        "customfield_10240": null,
        "customfield_10241": null,
        "customfield_10000": "com",
        "environment": null,
        "customfield_10238": null,
        "customfield_10513": [],
        "customfield_10514": [],
        "customfield_10516": [],
        "duedate": null,
        "customfield_10519": null
    }
},
{
    "expand": "operations,versionedRepresentations,editmeta,changelog,renderedFields",
    "id": "10164",
    "self": "https://pr.myproject.net/sd/rest/api/2/issue/10164",
    "key": "WO-23",
    "fields": {
        "customfield_10230": null,
        "fixVersions": [],
        "customfield_10231": null,
        "resolution": {
            "self": "https://pr.myproject.net/sd/rest/api/2/resolution/10100",
            "id": "10100",
            "description": "This issue was not approved.",
            "name": "Declined"
        },
        "customfield_10510": [],            
        "customfield_10503": [],
        "customfield_10229": null,
        "lastViewed": null,
        "customfield_10220": null,
        "priority": null,
        "customfield_10100": null,
        "customfield_10101": null,
        "labels": [],
        "timeestimate": null,
        "versions": [],
        "customfield_10219": null,
        "issuelinks": [],
        "assignee": {
            "self": "https://pr.myproject.net/sd/rest/api/2/user?username=crewManagerTest",
            "name": "crewManagerTest",
            "key": "crewmanagertest",
            "emailAddress": "crewManagerTest@crewManagerTest.com",
            "avatarUrls": {
                "48x48": "https://secure.myproject.com/avatar/208c23b0f1be06c82402c1548a463e3e?d=mm&s=48",
                "24x24": "https://secure.myproject.com/avatar/208c23b0f1be06c82402c1548a463e3e?d=mm&s=24"
            },
            "displayName": "crewManagerTest",
            "active": true,
            "timeZone": "Europe"
        },
        "status": {
            "self": "https://pr.myproject.net/sd/rest/api/2/status/10145",
            "description": "",
            "iconUrl": "https://pr.myproject.net/sd/images/icons/statuses/generic.png",
            "name": "Rejected",
            "id": "10145",
            "statusCategory": {
                "self": "https://pr.myproject.net/sd/rest/api/2/statuscategory/3",
                "id": 3,
                "key": "done",
                "colorName": "green",
                "name": "Done"
            }
        },
        "components": [],
        "customfield_10296": "CF-40",           
        "customfield_10603": null,
        "aggregatetimeestimate": null,
        "customfield_10604": "0",
        "customfield_10606": "",
        "creator": {
            "self": "https://pr.myproject.net/sd/rest/api/2/user?username=atlas",
            "name": "atlas",
            "key": "atlas",
            "emailAddress": "me@myproject.com",
            "avatarUrls": {
                "48x48": "https://pr.myproject.net/sd/secure/useravatar?ownerId=atlas&avatarId=10609",
                "24x24": "https://pr.myproject.net/sd/secure/useravatar?size=small&ownerId=atlas&avatarId=10609"
            },
            "displayName": "JIRA user",
            "active": true,
            "timeZone": "Europe"
        },
        "customfield_10280": null,
        "subtasks": [],
        "reporter": {
            "self": "https://pr.myproject.net/sd/rest/api/2/user?username=atlas",
            "name": "atlas",
            "key": "atlas",
            "emailAddress": "me@myproject.com",
            "avatarUrls": {
                "48x48": "https://pr.myproject.net/sd/secure/useravatar?ownerId=atlas&avatarId=10609",
                "24x24": "https://pr.myproject.net/sd/secure/useravatar?size=small&ownerId=atlas&avatarId=10609"
            },
            "displayName": "JIRA user",
            "active": true,
            "timeZone": "Europe"
        },
        "customfield_10285": null,
        "customfield_10286": null,
        "aggregateprogress": {
            "progress": 0,
            "total": 0
        },
        "progress": {
            "progress": 0,
            "total": 0
        },
        "votes": {
            "self": "https://pr.myproject.net/sd/rest/api/2/issue/WO-23/votes",
            "votes": 0,
            "hasVoted": false
        },
        "issuetype": {
            "self": "https://pr.myproject.net/sd/rest/api/2/issuetype/10116",
            "id": "10116",
            "description": "",
            "iconUrl": "https://pr.myproject.net/sd/secure/viewavatar?size=xsmall&avatarId=10300&avatarType=issuetype",
            "name": "Survey",
            "subtask": false,
            "avatarId": 10300
        },
        "customfield_10270": null,
        "timespent": null,
        "customfield_10271": null,
        "customfield_10272": null,
        "customfield_10273": null,
        "project": {
            "self": "https://pr.myproject.net/sd/rest/api/2/project/10103",
            "id": "10103",
            "key": "WO",
            "name": "Field Service",
            "avatarUrls": {
                "48x48": "https://pr.myproject.net/sd/secure/projectavatar?avatarId=10324",
                "24x24": "https://pr.myproject.net/sd/secure/projectavatar?size=small&avatarId=10324"
            }
        },
        "customfield_10275": null,
        "aggregatetimespent": null,
        "resolutiondate": "2017-07-02T15:10:40.000+0300",
        "workratio": -1,
        "watches": {
            "self": "https://pr.myproject.net/sd/rest/api/2/issue/WO-23/watchers",
            "watchCount": 1,
            "isWatching": false
        },
        "created": "2017-06-07T18:21:24.000+0300",
        "updated": "2017-07-02T15:10:40.000+0300",
        "timeoriginalestimate": null,
        "description": null,
        "summary": "Mobile Test 3",
        "customfield_10240": null,
        "customfield_10241": null,
        "customfield_10000": "com",
        "environment": null,
        "customfield_10238": null,
        "customfield_10513": [],
        "customfield_10514": [],
        "customfield_10516": [],
        "duedate": null,
        "customfield_10519": null
    }
},
{
    "expand": "operations,versionedRepresentations,editmeta,changelog,renderedFields",
    "id": "10162",
    "self": "https://pr.myproject.net/sd/rest/api/2/issue/10162",
    "key": "WO-22",
    "fields": {
        "customfield_10230": null,
        "fixVersions": [],
        "customfield_10231": null,
        "resolution": null,
        "customfield_10510": [],            
        "customfield_10503": [],
        "customfield_10229": null,      
        "lastViewed": "2017-12-01T02:07:05.368+0200",
        "customfield_10220": null,
        "priority": null,
        "customfield_10100": null,
        "customfield_10101": null,
        "labels": [],
        "timeestimate": null,
        "versions": [],
        "customfield_10219": null,
        "issuelinks": [],
        "assignee": {
            "self": "https://pr.myproject.net/sd/rest/api/2/user?username=crewManagerTest",
            "name": "crewManagerTest",
            "key": "crewmanagertest",
            "emailAddress": "crewManagerTest@crewManagerTest.com",
            "avatarUrls": {
                "48x48": "https://secure.myproject.com/avatar/208c23b0f1be06c82402c1548a463e3e?d=mm&s=48",
                "24x24": "https://secure.myproject.com/avatar/208c23b0f1be06c82402c1548a463e3e?d=mm&s=24"
            },
            "displayName": "crewManagerTest",
            "active": true,
            "timeZone": "Europe"
        },
        "status": {
            "self": "https://pr.myproject.net/sd/rest/api/2/status/10000",
            "description": "",
            "iconUrl": "https://pr.myproject.net/sd/images/icons/status_generic.gif",
            "name": "To Do",
            "id": "10000",
            "statusCategory": {
                "self": "https://pr.myproject.net/sd/rest/api/2/statuscategory/2",
                "id": 2,
                "key": "new",
                "colorName": "blue-gray",
                "name": "To Do"
            }
        },
        "components": [],
        "customfield_10296": "CF-39",
        "customfield_10603": null,
        "aggregatetimeestimate": null,
        "customfield_10604": "0",
        "customfield_10606": "",
        "creator": {
            "self": "https://pr.myproject.net/sd/rest/api/2/user?username=atlas",
            "name": "atlas",
            "key": "atlas",
            "emailAddress": "me@myproject.com",
            "avatarUrls": {
                "48x48": "https://pr.myproject.net/sd/secure/useravatar?ownerId=atlas&avatarId=10609",
                "24x24": "https://pr.myproject.net/sd/secure/useravatar?size=small&ownerId=atlas&avatarId=10609"
            },
            "displayName": "JIRA user",
            "active": true,
            "timeZone": "Europe"
        },
        "customfield_10280": null,
        "subtasks": [],
        "reporter": {
            "self": "https://pr.myproject.net/sd/rest/api/2/user?username=atlas",
            "name": "atlas",
            "key": "atlas",
            "emailAddress": "me@myproject.com",
            "avatarUrls": {
                "48x48": "https://pr.myproject.net/sd/secure/useravatar?ownerId=atlas&avatarId=10609",
                "24x24": "https://pr.myproject.net/sd/secure/useravatar?size=small&ownerId=atlas&avatarId=10609"
            },
            "displayName": "JIRA user",
            "active": true,
            "timeZone": "Europe"
        },
        "customfield_10285": null,
        "customfield_10286": null,
        "aggregateprogress": {
            "progress": 0,
            "total": 0
        },
        "progress": {
            "progress": 0,
            "total": 0
        },
        "votes": {
            "self": "https://pr.myproject.net/sd/rest/api/2/issue/WO-22/votes",
            "votes": 0,
            "hasVoted": false
        },
        "issuetype": {
            "self": "https://pr.myproject.net/sd/rest/api/2/issuetype/10116",
            "id": "10116",
            "description": "",
            "iconUrl": "https://pr.myproject.net/sd/secure/viewavatar?size=xsmall&avatarId=10300&avatarType=issuetype",
            "name": "Survey",
            "subtask": false,
            "avatarId": 10300
        },
        "customfield_10270": null,
        "timespent": null,
        "customfield_10271": null,
        "customfield_10272": null,
        "customfield_10273": null,
        "project": {
            "self": "https://pr.myproject.net/sd/rest/api/2/project/10103",
            "id": "10103",
            "key": "WO",
            "name": "Field Service",
            "avatarUrls": {
                "48x48": "https://pr.myproject.net/sd/secure/projectavatar?avatarId=10324",
                "24x24": "https://pr.myproject.net/sd/secure/projectavatar?size=small&avatarId=10324"
            }
        },
        "customfield_10275": null,
        "aggregatetimespent": null,
        "resolutiondate": null,
        "workratio": -1,
        "watches": {
            "self": "https://pr.myproject.net/sd/rest/api/2/issue/WO-22/watchers",
            "watchCount": 1,
            "isWatching": false
        },
        "created": "2017-06-07T18:19:36.000+0300",
        "updated": "2017-06-07T18:19:36.000+0300",
        "timeoriginalestimate": null,
        "description": null,
        "summary": "Mobile Test 2",
        "customfield_10240": null,
        "customfield_10241": null,
        "customfield_10000": "com",
        "environment": null,
        "customfield_10238": null,
        "customfield_10513": [],
        "customfield_10514": [],
        "customfield_10516": [],
        "duedate": null,
        "customfield_10519": null
    }
},
{
    "expand": "operations,versionedRepresentations,editmeta,changelog,renderedFields",
    "id": "10160",
    "self": "https://pr.myproject.net/sd/rest/api/2/issue/10160",
    "key": "WO-21",
    "fields": {
        "customfield_10230": null,
        "fixVersions": [],
        "customfield_10231": null,
        "resolution": {
            "self": "https://pr.myproject.net/sd/rest/api/2/resolution/10100",
            "id": "10100",
            "description": "This issue was not approved.",
            "name": "Declined"
        },
        "customfield_10510": [],            
        "customfield_10503": [],
        "customfield_10229": null,          
        "lastViewed": null,
        "customfield_10220": null,
        "priority": null,
        "customfield_10100": null,
        "customfield_10101": null,
        "labels": [],
        "timeestimate": null,
        "versions": [],
        "customfield_10219": null,
        "issuelinks": [],
        "assignee": {
            "self": "https://pr.myproject.net/sd/rest/api/2/user?username=crewManagerTest",
            "name": "crewManagerTest",
            "key": "crewmanagertest",
            "emailAddress": "crewManagerTest@crewManagerTest.com",
            "avatarUrls": {
                "48x48": "https://secure.myproject.com/avatar/208c23b0f1be06c82402c1548a463e3e?d=mm&s=48",
                "24x24": "https://secure.myproject.com/avatar/208c23b0f1be06c82402c1548a463e3e?d=mm&s=24"
            },
            "displayName": "crewManagerTest",
            "active": true,
            "timeZone": "Europe"
        },
        "status": {
            "self": "https://pr.myproject.net/sd/rest/api/2/status/10145",
            "description": "",
            "iconUrl": "https://pr.myproject.net/sd/images/icons/statuses/generic.png",
            "name": "Rejected",
            "id": "10145",
            "statusCategory": {
                "self": "https://pr.myproject.net/sd/rest/api/2/statuscategory/3",
                "id": 3,
                "key": "done",
                "colorName": "green",
                "name": "Done"
            }
        },
        "components": [],
        "customfield_10296": "CF-38",
        "customfield_10603": null,
        "aggregatetimeestimate": null,
        "customfield_10604": "0",
        "customfield_10606": "",
        "creator": {
            "self": "https://pr.myproject.net/sd/rest/api/2/user?username=atlas",
            "name": "atlas",
            "key": "atlas",
            "emailAddress": "me@myproject.com",
            "avatarUrls": {
                "48x48": "https://pr.myproject.net/sd/secure/useravatar?ownerId=atlas&avatarId=10609",
                "24x24": "https://pr.myproject.net/sd/secure/useravatar?size=small&ownerId=atlas&avatarId=10609"
            },
            "displayName": "JIRA user",
            "active": true,
            "timeZone": "Europe"
        },
        "customfield_10280": null,
        "subtasks": [],
        "reporter": {
            "self": "https://pr.myproject.net/sd/rest/api/2/user?username=atlas",
            "name": "atlas",
            "key": "atlas",
            "emailAddress": "me@myproject.com",
            "avatarUrls": {
                "48x48": "https://pr.myproject.net/sd/secure/useravatar?ownerId=atlas&avatarId=10609",
                "24x24": "https://pr.myproject.net/sd/secure/useravatar?size=small&ownerId=atlas&avatarId=10609"
            },
            "displayName": "JIRA user",
            "active": true,
            "timeZone": "Europe"
        },
        "customfield_10285": null,
        "customfield_10286": null,
        "aggregateprogress": {
            "progress": 0,
            "total": 0
        },
        "progress": {
            "progress": 0,
            "total": 0
        },
        "votes": {
            "self": "https://pr.myproject.net/sd/rest/api/2/issue/WO-21/votes",
            "votes": 0,
            "hasVoted": false
        },
        "issuetype": {
            "self": "https://pr.myproject.net/sd/rest/api/2/issuetype/10116",
            "id": "10116",
            "description": "",
            "iconUrl": "https://pr.myproject.net/sd/secure/viewavatar?size=xsmall&avatarId=10300&avatarType=issuetype",
            "name": "Survey",
            "subtask": false,
            "avatarId": 10300
        },
        "customfield_10270": null,
        "timespent": null,
        "customfield_10271": null,
        "customfield_10272": null,
        "customfield_10273": null,
        "project": {
            "self": "https://pr.myproject.net/sd/rest/api/2/project/10103",
            "id": "10103",
            "key": "WO",
            "name": "Field Service",
            "avatarUrls": {
                "48x48": "https://pr.myproject.net/sd/secure/projectavatar?avatarId=10324",
                "24x24": "https://pr.myproject.net/sd/secure/projectavatar?size=small&avatarId=10324"
            }
        },
        "customfield_10275": null,
        "aggregatetimespent": null,
        "resolutiondate": "2017-11-27T15:43:43.000+0200",
        "workratio": -1,
        "watches": {
            "self": "https://pr.myproject.net/sd/rest/api/2/issue/WO-21/watchers",
            "watchCount": 1,
            "isWatching": false
        },
        "created": "2017-06-07T14:44:34.000+0300",
        "updated": "2017-11-27T15:43:43.000+0200",
        "timeoriginalestimate": null,
        "description": null,
        "summary": "Mobile Test",
        "customfield_10240": null,
        "customfield_10241": null,
        "customfield_10000": "com",
        "environment": null,
        "customfield_10238": null,
        "customfield_10513": [],
        "customfield_10514": [],
        "customfield_10516": [],
        "duedate": null,
        "customfield_10519": null
    }
},
{
    "expand": "operations,versionedRepresentations,editmeta,changelog,renderedFields",
    "id": "10158",
    "self": "https://pr.myproject.net/sd/rest/api/2/issue/10158",
    "key": "WO-20",
    "fields": {
        "customfield_10230": null,
        "fixVersions": [],
        "customfield_10231": null,
        "resolution": {
            "self": "https://pr.myproject.net/sd/rest/api/2/resolution/10000",
            "id": "10000",
            "description": "Work has been completed on this issue.",
            "name": "Done"
        },
        "customfield_10510": [],            
        "customfield_10503": [],
        "customfield_10229": null,          
        "lastViewed": null,
        "customfield_10220": null,
        "priority": null,
        "customfield_10100": null,
        "customfield_10101": null,
        "labels": [],
        "timeestimate": null,
        "versions": [],
        "customfield_10219": null,
        "issuelinks": [],
        "assignee": {
            "self": "https://pr.myproject.net/sd/rest/api/2/user?username=crewManagerTest",
            "name": "crewManagerTest",
            "key": "crewmanagertest",
            "emailAddress": "crewManagerTest@crewManagerTest.com",
            "avatarUrls": {
                "48x48": "https://secure.myproject.com/avatar/208c23b0f1be06c82402c1548a463e3e?d=mm&s=48",
                "24x24": "https://secure.myproject.com/avatar/208c23b0f1be06c82402c1548a463e3e?d=mm&s=24"
            },
            "displayName": "crewManagerTest",
            "active": true,
            "timeZone": "Europe"
        },
        "status": {
            "self": "https://pr.myproject.net/sd/rest/api/2/status/10001",
            "description": "",
            "iconUrl": "https://pr.myproject.net/sd/images/icons/status_generic.gif",
            "name": "Done",
            "id": "10001",
            "statusCategory": {
                "self": "https://pr.myproject.net/sd/rest/api/2/statuscategory/3",
                "id": 3,
                "key": "done",
                "colorName": "green",
                "name": "Done"
            }
        },
        "components": [],
        "customfield_10296": "CF-37",
        "customfield_10603": null,
        "aggregatetimeestimate": null,
        "customfield_10604": "0",
        "customfield_10606": "",
        "creator": {
            "self": "https://pr.myproject.net/sd/rest/api/2/user?username=atlas",
            "name": "atlas",
            "key": "atlas",
            "emailAddress": "me@myproject.com",
            "avatarUrls": {
                "48x48": "https://pr.myproject.net/sd/secure/useravatar?ownerId=atlas&avatarId=10609",
                "24x24": "https://pr.myproject.net/sd/secure/useravatar?size=small&ownerId=atlas&avatarId=10609"
            },
            "displayName": "JIRA user",
            "active": true,
            "timeZone": "Europe"
        },
        "customfield_10280": null,
        "subtasks": [],
        "reporter": {
            "self": "https://pr.myproject.net/sd/rest/api/2/user?username=atlas",
            "name": "atlas",
            "key": "atlas",
            "emailAddress": "me@myproject.com",
            "avatarUrls": {
                "48x48": "https://pr.myproject.net/sd/secure/useravatar?ownerId=atlas&avatarId=10609",
                "24x24": "https://pr.myproject.net/sd/secure/useravatar?size=small&ownerId=atlas&avatarId=10609"
            },
            "displayName": "JIRA user",
            "active": true,
            "timeZone": "Europe"
        },
        "customfield_10285": null,
        "customfield_10286": null,
        "aggregateprogress": {
            "progress": 0,
            "total": 0
        },
        "progress": {
            "progress": 0,
            "total": 0
        },
        "votes": {
            "self": "https://pr.myproject.net/sd/rest/api/2/issue/WO-20/votes",
            "votes": 0,
            "hasVoted": false
        },
        "issuetype": {
            "self": "https://pr.myproject.net/sd/rest/api/2/issuetype/10116",
            "id": "10116",
            "description": "",
            "iconUrl": "https://pr.myproject.net/sd/secure/viewavatar?size=xsmall&avatarId=10300&avatarType=issuetype",
            "name": "Survey",
            "subtask": false,
            "avatarId": 10300
        },
        "customfield_10270": null,
        "timespent": null,
        "customfield_10271": null,
        "customfield_10272": null,
        "customfield_10273": null,
        "project": {
            "self": "https://pr.myproject.net/sd/rest/api/2/project/10103",
            "id": "10103",
            "key": "WO",
            "name": "Field Service",
            "avatarUrls": {
                "48x48": "https://pr.myproject.net/sd/secure/projectavatar?avatarId=10324",
                "24x24": "https://pr.myproject.net/sd/secure/projectavatar?size=small&avatarId=10324"
            }
        },
        "customfield_10275": null,
        "aggregatetimespent": null,
        "resolutiondate": "2017-06-07T14:29:33.000+0300",
        "workratio": -1,
        "watches": {
            "self": "https://pr.myproject.net/sd/rest/api/2/issue/WO-20/watchers",
            "watchCount": 1,
            "isWatching": false
        },
        "created": "2017-06-07T14:07:26.000+0300",
        "updated": "2017-06-07T14:56:58.000+0300",
        "timeoriginalestimate": null,
        "description": "Test Description",
        "summary": "Test Summary",
        "customfield_10240": null,
        "customfield_10241": null,
        "customfield_10000": "com",
        "environment": null,
        "customfield_10238": null,
        "customfield_10513": [],
        "customfield_10514": [],
        "customfield_10516": [],
        "duedate": null,
        "customfield_10519": null
    }
}]

} 我试图阅读这段代码:

JObject oJson = JObject.Parse(json);
var issueList = (from colIssies in oJson["expand"]["issues"]
select colIssies).ToList();

但是我收到此错误:System.InvalidOperationException:'无法访问Newtonsoft.Json.Linq.JValue上的子值。' 谁能帮我? 提前谢谢。

1 个答案:

答案 0 :(得分:3)

有很多方法可以将json反序列化为一个对象,这一切都归结为你之后需要对数据做什么。 让我们假设您只需要数据的一个子集,因此您可以使用给定模板反序列化为匿名对象(使用json.net

var definition = new 
{ 
    expand = default(string),
    startAt = default(int),
    maxResults = default(int),
    total = default(int),
    issues = new []{
        new {
            expand = default(string),
            id = default(int),
            key = default(string),
            fields = new {
                created = default(DateTimeOffset),
                creator = new {
                    name = default(string),
                },
                assignee = new {
                    name = default(string),
                    key = default(string),
                    emailAddress = default(string),
                    displayName = default(string),
                    timeZone = default(string),
                },
                project = new {
                    name = default(string),
                },
                issuetype = new {
                    name = default(string),
                },
                status = new {
                    id = default(int),
                    name = default(string),
                },
            },
            etc= "..."
        }
    }
};

然后您可以灵活地将提取的数据投影到任何给定的形状

var instance = JsonConvert.DeserializeAnonymousType(data, definition);

var projection = from issue in instance.issues
                 let date = issue.fields?.created
                 where date <= DateTime.Now
                 select new
                 {
                     id = issue.id,
                     key = issue.key,
                     type = issue.fields?.issuetype?.name,
                     created = issue.fields?.created,
                     project = issue.fields?.project?.name,
                     creator = issue.fields?.creator?.name,
                     assignee = issue.fields?.assignee?.name,
                     status = issue.fields?.status?.name,
                 };

当然有完整的智能感知支持

enter image description here