在Visual Studio中,我能够与Jira建立连接,返回字符串(缩写为示例中的一个实例)
"expand": "operations,versionedRepresentations,editmeta,changelog,renderedFields",
"id": "15237",
"self": "https://companyName.atlassian.net/rest/agile/1.0/issue/15237",
"key": "THU-219",
"fields": {
"customfield_10110": null,
"fixVersions": [],
"customfield_10111": null,
"customfield_10112": null,
"resolution": null,
"customfield_10113": [
"com.atlassian.greenhopper.service.sprint.Sprint@a34aea2[id=53,rapidViewId=9,state=CLOSED,name=THU Sprint 7,goal=Survive!,startDate=2018-03-07T22:33:01.297Z,endDate=2018-03-21T22:33:00.000Z,completeDate=2018-03-20T19:16:10.159Z,sequence=53]",
"com.atlassian.greenhopper.service.sprint.Sprint@28b8057[id=58,rapidViewId=9,state=ACTIVE,name=THU Sprint 8,goal=make sure fixes fix ticket,startDate=2018-03-20T19:16:10.291Z,endDate=2018-04-03T19:16:00.000Z,completeDate=<null>,sequence=58]",
"com.atlassian.greenhopper.service.sprint.Sprint@3e1efb35[id=43,rapidViewId=9,state=CLOSED,name=THU Sprint 5,goal=,startDate=2018-02-06T20:44:37.751Z,endDate=2018-02-20T20:44:00.000Z,completeDate=2018-02-20T20:15:10.688Z,sequence=43]",
"com.atlassian.greenhopper.service.sprint.Sprint@2ce8e5a0[id=48,rapidViewId=9,state=CLOSED,name=THU Sprint 6,goal=,startDate=2018-02-20T20:15:01.461Z,endDate=2018-03-06T20:15:00.000Z,completeDate=2018-03-07T22:32:22.792Z,sequence=48]"
],
"customfield_10114": "1|hzz39z:",
"customfield_10500": null,
"customfield_10104": null,
"customfield_10105": null,
"customfield_10501": null,
"customfield_10106": null,
"customfield_10502": null,
"customfield_10503": null,
"customfield_10107": null,
"customfield_10108": null,
"customfield_10109": null,
"lastViewed": null,
"epic": {
"id": 15229,
"key": "THU-211",
"self": "https://companyName.atlassian.net/rest/agile/1.0/epic/15229",
"name": "project Name",
"summary": "Epic encompassing all TBD-related issues",
"color": {
"key": "color_2"
},
"done": false
},
"priority": {
"self": "https://nebook.atlassian.net/rest/api/2/priority/1",
"iconUrl": "https://companyName.atlassian.net/images/icons/priorities/highest.svg",
"name": "Highest",
"id": "1"
},
"customfield_10100": "2018-01-23T17:12:27.999-0600",
"customfield_10101": null,
"customfield_10102": null,
"labels": [
"user's first name"
],
"customfield_10103": null,
"customfield_10731": null,
"customfield_10610": null,
"customfield_10611": null,
"customfield_10733": null,
"customfield_10612": null,
"customfield_10613": null,
"timeestimate": null,
"customfield_10614": null,
"aggregatetimeoriginalestimate": null,
"customfield_10735": null,
"customfield_10615": null,
"versions": [],
"customfield_10616": null,
"customfield_10617": null,
"issuelinks": [
{
"id": "14337",
"self": "https://companyName.atlassian.net/rest/api/2/issueLink/14337",
"type": {
"id": "10000",
"name": "Blocks",
"inward": "is blocked by",
"outward": "blocks",
"self": "https://companyName.atlassian.net/rest/api/2/issueLinkType/10000"
},
"inwardIssue": {
"id": "18233",
"key": "THU-289",
"self": "https://companyName.atlassian.net/rest/api/2/issue/18233",
"fields": {
"summary": "summary",
"status": {
"self": "https://companyName.atlassian.net/rest/api/2/status/10804",
"description": "",
"iconUrl": "https://companyName.atlassian.net/images/icons/statuses/generic.png",
"name": "Code Review",
"id": "10804",
"statusCategory": {
"self": "https://companyName.atlassian.net/rest/api/2/statuscategory/4",
"id": 4,
"key": "indeterminate",
"colorName": "yellow",
"name": "In Progress"
}
},
"priority": {
"self": "https://companyName.atlassian.net/rest/api/2/priority/1",
"iconUrl": "https://companyName.atlassian.net/images/icons/priorities/highest.svg",
"name": "Highest",
"id": "1"
},
"issuetype": {
"self": "https://companyName.atlassian.net/rest/api/2/issuetype/10300",
"id": "10300",
"description": "Created by Jira Agile - do not edit or delete. Issue type for a user story.",
"iconUrl": "https://companyName.atlassian.net/images/icons/issuetypes/story.svg",
"name": "Story",
"subtask": false
}
}
}
},
{
"id": "14336",
"self": "https://companyName.atlassian.net/rest/api/2/issueLink/14336",
"type": {
"id": "10001",
"name": "Cloners",
"inward": "is cloned by",
"outward": "clones",
"self": "https://companyName.atlassian.net/rest/api/2/issueLinkType/10001"
},
"inwardIssue": {
"id": "18233",
"key": "THU-289",
"self": "https://companyName.atlassian.net/rest/api/2/issue/18233",
"fields": {
"summary": "summary",
"status": {
"self": "https://companyName.atlassian.net/rest/api/2/status/10804",
"description": "",
"iconUrl": "https://companyName.atlassian.net/images/icons/statuses/generic.png",
"name": "Code Review",
"id": "10804",
"statusCategory": {
"self": "https://companyName.atlassian.net/rest/api/2/statuscategory/4",
"id": 4,
"key": "indeterminate",
"colorName": "yellow",
"name": "In Progress"
}
},
"priority": {
"self": "https://companyName.atlassian.net/rest/api/2/priority/1",
"iconUrl": "https://companyName.atlassian.net/images/icons/priorities/highest.svg",
"name": "Highest",
"id": "1"
},
"issuetype": {
"self": "https://companyName.atlassian.net/rest/api/2/issuetype/10300",
"id": "10300",
"description": "Created by Jira Agile - do not edit or delete. Issue type for a user story.",
"iconUrl": "https://companyName.atlassian.net/images/icons/issuetypes/story.svg",
"name": "Story",
"subtask": false
}
}
}
}
],
"assignee": null,
"status": {
"self": "https://companyName.atlassian.net/rest/api/2/status/10804",
"description": "",
"iconUrl": "https://companyName.atlassian.net/images/icons/statuses/generic.png",
"name": "Code Review",
"id": "10804",
"statusCategory": {
"self": "https://companyName.atlassian.net/rest/api/2/statuscategory/4",
"id": 4,
"key": "indeterminate",
"colorName": "yellow",
"name": "In Progress"
}
},
"components": [],
"customfield_10730": null,
"customfield_10600": null,
"customfield_10601": null,
"customfield_10602": null,
"aggregatetimeestimate": null,
"customfield_10603": null,
"customfield_10604": null,
"customfield_10605": null,
"customfield_10727": null,
"customfield_10606": null,
"customfield_10728": null,
"customfield_10607": null,
"customfield_10608": null,
"customfield_10729": null,
"customfield_10609": null,
"creator": {
"self": "https://companyName.atlassian.net/rest/api/2/user?username=name",
"name": "name",
"key": "key",
"accountId": "accountId",
"emailAddress": "email",
"avatarUrls": {
"48x48": "https://avatar-cdn.atlassian.com/40f53dffbd45ed6f545a40ec91d4843f?s=48&d=https%3A%2F%2Fsecure.gravatar.com%2Favatar%2F40f53dffbd45ed6f545a40ec91d4843f%3Fd%3Dmm%26s%3D48%26noRedirect%3Dtrue",
"24x24": "https://avatar-cdn.atlassian.com/40f53dffbd45ed6f545a40ec91d4843f?s=24&d=https%3A%2F%2Fsecure.gravatar.com%2Favatar%2F40f53dffbd45ed6f545a40ec91d4843f%3Fd%3Dmm%26s%3D24%26noRedirect%3Dtrue",
"16x16": "https://avatar-cdn.atlassian.com/40f53dffbd45ed6f545a40ec91d4843f?s=16&d=https%3A%2F%2Fsecure.gravatar.com%2Favatar%2F40f53dffbd45ed6f545a40ec91d4843f%3Fd%3Dmm%26s%3D16%26noRedirect%3Dtrue",
"32x32": "https://avatar-cdn.atlassian.com/40f53dffbd45ed6f545a40ec91d4843f?s=32&d=https%3A%2F%2Fsecure.gravatar.com%2Favatar%2F40f53dffbd45ed6f545a40ec91d4843f%3Fd%3Dmm%26s%3D32%26noRedirect%3Dtrue"
},
"displayName": "name",
"active": true,
"timeZone": "America/Chicago"
},
"subtasks": [],
"reporter": {
"self": "https://companyName.atlassian.net/rest/api/2/user?username=name",
"name": "name",
"key": "key",
"accountId": "557058:ecce9327-53cc-4787-bcd5-ecf16309600b",
"emailAddress": "email",
"avatarUrls": {
"48x48": "https://avatar-cdn.atlassian.com/40f53dffbd45ed6f545a40ec91d4843f?s=48&d=https%3A%2F%2Fsecure.gravatar.com%2Favatar%2F40f53dffbd45ed6f545a40ec91d4843f%3Fd%3Dmm%26s%3D48%26noRedirect%3Dtrue",
"24x24": "https://avatar-cdn.atlassian.com/40f53dffbd45ed6f545a40ec91d4843f?s=24&d=https%3A%2F%2Fsecure.gravatar.com%2Favatar%2F40f53dffbd45ed6f545a40ec91d4843f%3Fd%3Dmm%26s%3D24%26noRedirect%3Dtrue",
"16x16": "https://avatar-cdn.atlassian.com/40f53dffbd45ed6f545a40ec91d4843f?s=16&d=https%3A%2F%2Fsecure.gravatar.com%2Favatar%2F40f53dffbd45ed6f545a40ec91d4843f%3Fd%3Dmm%26s%3D16%26noRedirect%3Dtrue",
"32x32": "https://avatar-cdn.atlassian.com/40f53dffbd45ed6f545a40ec91d4843f?s=32&d=https%3A%2F%2Fsecure.gravatar.com%2Favatar%2F40f53dffbd45ed6f545a40ec91d4843f%3Fd%3Dmm%26s%3D32%26noRedirect%3Dtrue"
},
"displayName": "name",
"active": true,
"timeZone": "America/Chicago"
},
"aggregateprogress": {
"progress": 0,
"total": 0
},
"customfield_10711": null,
"customfield_10712": null,
"closedSprints": [
{
"id": 53,
"self": "https://companyName.atlassian.net/rest/agile/1.0/sprint/53",
"state": "closed",
"name": "THU Sprint 7",
"startDate": "2018-03-07T22:33:01.297Z",
"endDate": "2018-03-21T22:33:00.000Z",
"completeDate": "2018-03-20T19:16:10.159Z",
"originBoardId": 9,
"goal": "Survive!"
},
{
"id": 43,
"self": "https://companyName.atlassian.net/rest/agile/1.0/sprint/43",
"state": "closed",
"name": "THU Sprint 5",
"startDate": "2018-02-06T20:44:37.751Z",
"endDate": "2018-02-20T20:44:00.000Z",
"completeDate": "2018-02-20T20:15:10.688Z",
"originBoardId": 9,
"goal": ""
},
{
"id": 48,
"self": "https://companyName.atlassian.net/rest/agile/1.0/sprint/48",
"state": "closed",
"name": "THU Sprint 6",
"startDate": "2018-02-20T20:15:01.461Z",
"endDate": "2018-03-06T20:15:00.000Z",
"completeDate": "2018-03-07T22:32:22.792Z",
"originBoardId": 9,
"goal": ""
}
],
"progress": {
"progress": 0,
"total": 0
},
"votes": {
"self": "https://companyName.atlassian.net/rest/api/2/issue/THU-219/votes",
"votes": 0,
"hasVoted": false
},
"worklog": {
"startAt": 0,
"maxResults": 20,
"total": 0,
"worklogs": []
},
"issuetype": {
"self": "https://companyName.atlassian.net/rest/api/2/issuetype/10300",
"id": "10300",
"description": "Created by Jira Agile - do not edit or delete. Issue type for a user story.",
"iconUrl": "https://companyName.atlassian.net/images/icons/issuetypes/story.svg",
"name": "Story",
"subtask": false
},
"timespent": null,
"sprint": {
"id": 58,
"self": "https://companyName.atlassian.net/rest/agile/1.0/sprint/58",
"state": "active",
"name": "THU Sprint 8",
"startDate": "2018-03-20T19:16:10.291Z",
"endDate": "2018-04-03T19:16:00.000Z",
"originBoardId": 9,
"goal": "make sure fixes fix ticket"
},
"project": {
"self": "https://nebook.atlassian.net/rest/api/2/project/11510",
"id": "11510",
"key": "THU",
"name": "name",
"projectTypeKey": "software",
"avatarUrls": {
"48x48": "https://nebook.atlassian.net/secure/projectavatar?avatarId=10324",
"24x24": "https://nebook.atlassian.net/secure/projectavatar?size=small&avatarId=10324",
"16x16": "https://nebook.atlassian.net/secure/projectavatar?size=xsmall&avatarId=10324",
"32x32": "https://nebook.atlassian.net/secure/projectavatar?size=medium&avatarId=10324"
}
},
"aggregatetimespent": null,
"resolutiondate": null,
"workratio": -1,
"watches": {
"self": "https://companyName.atlassian.net/rest/api/2/issue/THU-219/watchers",
"watchCount": 2,
"isWatching": false
},
"created": "2017-12-14T18:01:28.505-0600",
"customfield_10300": null,
"customfield_10301": null,
"updated": "2018-03-20T14:16:13.195-0500",
"timeoriginalestimate": null,
"description": "description",
"timetracking": {},
"customfield_10401": [],
"customfield_10402": null,
"customfield_10006": "THU-211",
"customfield_10403": null,
"security": null,
"customfield_10007": null,
"attachment": [],
"flagged": false,
"summary": "summary",
"customfield_10000": "{}",
"customfield_10001": null,
"customfield_10002": null,
"customfield_10400": null,
"environment": null,
"duedate": null,
"comment": {
"comments": [
{
"self": "https://companyName.atlassian.net/rest/api/2/issue/15237/comment/23890",
"id": "23890",
"author": {
"self": "https://companyName.atlassian.net/rest/api/2/user?username=name",
"name": "name",
"key": "key",
"accountId": "accountId",
"emailAddress": "email",
"avatarUrls": {
"48x48": "https://avatar-cdn.atlassian.com/b232453b514d10d65f986fe7f2df592c?s=48&d=https%3A%2F%2Fsecure.gravatar.com%2Favatar%2Fb232453b514d10d65f986fe7f2df592c%3Fd%3Dmm%26s%3D48%26noRedirect%3Dtrue",
"24x24": "https://avatar-cdn.atlassian.com/b232453b514d10d65f986fe7f2df592c?s=24&d=https%3A%2F%2Fsecure.gravatar.com%2Favatar%2Fb232453b514d10d65f986fe7f2df592c%3Fd%3Dmm%26s%3D24%26noRedirect%3Dtrue",
"16x16": "https://avatar-cdn.atlassian.com/b232453b514d10d65f986fe7f2df592c?s=16&d=https%3A%2F%2Fsecure.gravatar.com%2Favatar%2Fb232453b514d10d65f986fe7f2df592c%3Fd%3Dmm%26s%3D16%26noRedirect%3Dtrue",
"32x32": "https://avatar-cdn.atlassian.com/b232453b514d10d65f986fe7f2df592c?s=32&d=https%3A%2F%2Fsecure.gravatar.com%2Favatar%2Fb232453b514d10d65f986fe7f2df592c%3Fd%3Dmm%26s%3D32%26noRedirect%3Dtrue"
},
"displayName": "name",
"active": true,
"timeZone": "America/Chicago"
},
"body": "text describing the issue",
"updateAuthor": {
"self": "https://companyName.atlassian.net/rest/api/2/user?username=name",
"name": "name",
"key": "key",
"accountId": "557058:d4a31d0e-7944-488b-9f89-fcfec87b95ac",
"emailAddress": "email",
"avatarUrls": {
"48x48": "https://avatar-cdn.atlassian.com/b232453b514d10d65f986fe7f2df592c?s=48&d=https%3A%2F%2Fsecure.gravatar.com%2Favatar%2Fb232453b514d10d65f986fe7f2df592c%3Fd%3Dmm%26s%3D48%26noRedirect%3Dtrue",
"24x24": "https://avatar-cdn.atlassian.com/b232453b514d10d65f986fe7f2df592c?s=24&d=https%3A%2F%2Fsecure.gravatar.com%2Favatar%2Fb232453b514d10d65f986fe7f2df592c%3Fd%3Dmm%26s%3D24%26noRedirect%3Dtrue",
"16x16": "https://avatar-cdn.atlassian.com/b232453b514d10d65f986fe7f2df592c?s=16&d=https%3A%2F%2Fsecure.gravatar.com%2Favatar%2Fb232453b514d10d65f986fe7f2df592c%3Fd%3Dmm%26s%3D16%26noRedirect%3Dtrue",
"32x32": "https://avatar-cdn.atlassian.com/b232453b514d10d65f986fe7f2df592c?s=32&d=https%3A%2F%2Fsecure.gravatar.com%2Favatar%2Fb232453b514d10d65f986fe7f2df592c%3Fd%3Dmm%26s%3D32%26noRedirect%3Dtrue"
},
"displayName": "name",
"active": true,
"timeZone": "America/Chicago"
},
"created": "2018-01-23T17:12:27.999-0600",
"updated": "2018-01-23T17:12:27.999-0600"
}
],
"maxResults": 1,
"total": 1,
"startAt": 0
}
}
},
我已经能够在这里找到一些处理这个问题的例子,但是我找不到任何处理重复关键词的事情,比如我的JSON数据。
我关心的唯一真实信息是最初的&#34; Key&#34;值(在这个例子中&#34; THU-219&#34;)和状态&#34; name&#34;领域&#34;领域&#34; - &GT; &#34; issuelinks&#34; - &GT; &#34; inwardIssue&#34; - &GT; &#34;字段&#34; - &GT; &#34;状态&#34; - &GT; &#34;名称&#34;
我希望能够以...的形式打印出来 关键:THU-219 \ n 状态:&#34;代码审核&#34;
为了达到这个目的,我尝试了这段代码(在我建立安全连接之后)其中respStr是包含上述代码段的整个字符串,每个问题的格式相同。我创建的课程错了吗?因为我无法获得预期的数据。我知道Visual Studio中有一个选项可以粘贴为JSON类&#34;但我收到的错误不允许我使用此功能,所以我需要一种方法来完成此操作而不依赖于粘贴特殊功能。
String respStr = response.Content;
JiraObject jira = JsonConvert.DeserializeObject<JiraObject>(respStr);
foreach (KeyValuePair<string, Key>kvp in jira.Issues)
{
Console.WriteLine("Key:" + kvp.Value.Keys);
Console.WriteLine("Status:" + kvp.Value.Status)
Console.WriteLine();
}
Console.ReadKey();
}
}
class JiraObject
{
[JsonProperty("issues")]
public Dictionary<string, issues> Issues { get; set; }
}
class issues
{
[JsonProperty("key")]
public Dictionary<string, Key> Keys { get; set; }
[JsonProperty("fields")]
public Dictionary<string, Fields> fields { get; set; }
}
class Key
{
public Key Keys { get; set; }
}
class Fields
{
[JsonProperty("issuelinks")]
public Dictionary<string, issuelinks> issueLinks { get; set; }
}
class issuelinks
{
[JsonProperty("inwardIssue")]
public Dictionary<string,inwardIssue> inwardIssues { get; set; }
}
class inwardIssue
{
[JsonProperty("fields")]
public Dictionary<string, inwardFields> inwardFields { get; set; }
}
class inwardFields
{
[JsonProperty("status")]
public Dictionary<string, status> status { get; set; }
}
class status
{
[JsonProperty("name")]
public Dictionary<string,name> name { get; set; }
}
class name
{
public name names { get; set; }
}
答案 0 :(得分:0)
凯文阿维尼翁指出,你的JSON是无效的。它错过了一个&#34; {&#34;在开始时你需要删除&#34;,&#34;最后,以便我们可以使用它(但这只是一个小问题)。
为了获得您需要的类,您可以将JSON转储到json2csharp.com。在你的情况下,我得到以下内容:
public class Color
{
public string key { get; set; }
}
public class Epic
{
public int id { get; set; }
public string key { get; set; }
public string self { get; set; }
public string name { get; set; }
public string summary { get; set; }
public Color color { get; set; }
public bool done { get; set; }
}
public class Priority
{
public string self { get; set; }
public string iconUrl { get; set; }
public string name { get; set; }
public string id { get; set; }
}
public class Type
{
public string id { get; set; }
public string name { get; set; }
public string inward { get; set; }
public string outward { get; set; }
public string self { get; set; }
}
public class StatusCategory
{
public string self { get; set; }
public int id { get; set; }
public string key { get; set; }
public string colorName { get; set; }
public string name { get; set; }
}
public class Status
{
public string self { get; set; }
public string description { get; set; }
public string iconUrl { get; set; }
public string name { get; set; }
public string id { get; set; }
public StatusCategory statusCategory { get; set; }
}
public class Priority2
{
public string self { get; set; }
public string iconUrl { get; set; }
public string name { get; set; }
public string id { get; set; }
}
public class Issuetype
{
public string self { get; set; }
public string id { get; set; }
public string description { get; set; }
public string iconUrl { get; set; }
public string name { get; set; }
public bool subtask { get; set; }
}
public class Fields2
{
public string summary { get; set; }
public Status status { get; set; }
public Priority2 priority { get; set; }
public Issuetype issuetype { get; set; }
}
public class InwardIssue
{
public string id { get; set; }
public string key { get; set; }
public string self { get; set; }
public Fields2 fields { get; set; }
}
public class Issuelink
{
public string id { get; set; }
public string self { get; set; }
public Type type { get; set; }
public InwardIssue inwardIssue { get; set; }
}
public class StatusCategory2
{
public string self { get; set; }
public int id { get; set; }
public string key { get; set; }
public string colorName { get; set; }
public string name { get; set; }
}
public class Status2
{
public string self { get; set; }
public string description { get; set; }
public string iconUrl { get; set; }
public string name { get; set; }
public string id { get; set; }
public StatusCategory2 statusCategory { get; set; }
}
public class AvatarUrls
{
public string __invalid_name__48x48 { get; set; }
public string __invalid_name__24x24 { get; set; }
public string __invalid_name__16x16 { get; set; }
public string __invalid_name__32x32 { get; set; }
}
public class Creator
{
public string self { get; set; }
public string name { get; set; }
public string key { get; set; }
public string accountId { get; set; }
public string emailAddress { get; set; }
public AvatarUrls avatarUrls { get; set; }
public string displayName { get; set; }
public bool active { get; set; }
public string timeZone { get; set; }
}
public class AvatarUrls2
{
public string __invalid_name__48x48 { get; set; }
public string __invalid_name__24x24 { get; set; }
public string __invalid_name__16x16 { get; set; }
public string __invalid_name__32x32 { get; set; }
}
public class Reporter
{
public string self { get; set; }
public string name { get; set; }
public string key { get; set; }
public string accountId { get; set; }
public string emailAddress { get; set; }
public AvatarUrls2 avatarUrls { get; set; }
public string displayName { get; set; }
public bool active { get; set; }
public string timeZone { get; set; }
}
public class Aggregateprogress
{
public int progress { get; set; }
public int total { get; set; }
}
public class ClosedSprint
{
public int id { get; set; }
public string self { get; set; }
public string state { get; set; }
public string name { get; set; }
public DateTime startDate { get; set; }
public DateTime endDate { get; set; }
public DateTime completeDate { get; set; }
public int originBoardId { get; set; }
public string goal { get; set; }
}
public class Progress
{
public int progress { get; set; }
public int total { get; set; }
}
public class Votes
{
public string self { get; set; }
public int votes { get; set; }
public bool hasVoted { get; set; }
}
public class Worklog
{
public int startAt { get; set; }
public int maxResults { get; set; }
public int total { get; set; }
public List<object> worklogs { get; set; }
}
public class Issuetype2
{
public string self { get; set; }
public string id { get; set; }
public string description { get; set; }
public string iconUrl { get; set; }
public string name { get; set; }
public bool subtask { get; set; }
}
public class Sprint
{
public int id { get; set; }
public string self { get; set; }
public string state { get; set; }
public string name { get; set; }
public DateTime startDate { get; set; }
public DateTime endDate { get; set; }
public int originBoardId { get; set; }
public string goal { get; set; }
}
public class AvatarUrls3
{
public string __invalid_name__48x48 { get; set; }
public string __invalid_name__24x24 { get; set; }
public string __invalid_name__16x16 { get; set; }
public string __invalid_name__32x32 { get; set; }
}
public class Project
{
public string self { get; set; }
public string id { get; set; }
public string key { get; set; }
public string name { get; set; }
public string projectTypeKey { get; set; }
public AvatarUrls3 avatarUrls { get; set; }
}
public class Watches
{
public string self { get; set; }
public int watchCount { get; set; }
public bool isWatching { get; set; }
}
public class Timetracking
{
}
public class AvatarUrls4
{
public string __invalid_name__48x48 { get; set; }
public string __invalid_name__24x24 { get; set; }
public string __invalid_name__16x16 { get; set; }
public string __invalid_name__32x32 { get; set; }
}
public class Author
{
public string self { get; set; }
public string name { get; set; }
public string key { get; set; }
public string accountId { get; set; }
public string emailAddress { get; set; }
public AvatarUrls4 avatarUrls { get; set; }
public string displayName { get; set; }
public bool active { get; set; }
public string timeZone { get; set; }
}
public class AvatarUrls5
{
public string __invalid_name__48x48 { get; set; }
public string __invalid_name__24x24 { get; set; }
public string __invalid_name__16x16 { get; set; }
public string __invalid_name__32x32 { get; set; }
}
public class UpdateAuthor
{
public string self { get; set; }
public string name { get; set; }
public string key { get; set; }
public string accountId { get; set; }
public string emailAddress { get; set; }
public AvatarUrls5 avatarUrls { get; set; }
public string displayName { get; set; }
public bool active { get; set; }
public string timeZone { get; set; }
}
public class Comment2
{
public string self { get; set; }
public string id { get; set; }
public Author author { get; set; }
public string body { get; set; }
public UpdateAuthor updateAuthor { get; set; }
public DateTime created { get; set; }
public DateTime updated { get; set; }
}
public class Comment
{
public List<Comment2> comments { get; set; }
public int maxResults { get; set; }
public int total { get; set; }
public int startAt { get; set; }
}
public class Fields
{
public object customfield_10110 { get; set; }
public List<object> fixVersions { get; set; }
public object customfield_10111 { get; set; }
public object customfield_10112 { get; set; }
public object resolution { get; set; }
public List<string> customfield_10113 { get; set; }
public string customfield_10114 { get; set; }
public object customfield_10500 { get; set; }
public object customfield_10104 { get; set; }
public object customfield_10105 { get; set; }
public object customfield_10501 { get; set; }
public object customfield_10106 { get; set; }
public object customfield_10502 { get; set; }
public object customfield_10503 { get; set; }
public object customfield_10107 { get; set; }
public object customfield_10108 { get; set; }
public object customfield_10109 { get; set; }
public object lastViewed { get; set; }
public Epic epic { get; set; }
public Priority priority { get; set; }
public DateTime customfield_10100 { get; set; }
public object customfield_10101 { get; set; }
public object customfield_10102 { get; set; }
public List<string> labels { get; set; }
public object customfield_10103 { get; set; }
public object customfield_10731 { get; set; }
public object customfield_10610 { get; set; }
public object customfield_10611 { get; set; }
public object customfield_10733 { get; set; }
public object customfield_10612 { get; set; }
public object customfield_10613 { get; set; }
public object timeestimate { get; set; }
public object customfield_10614 { get; set; }
public object aggregatetimeoriginalestimate { get; set; }
public object customfield_10735 { get; set; }
public object customfield_10615 { get; set; }
public List<object> versions { get; set; }
public object customfield_10616 { get; set; }
public object customfield_10617 { get; set; }
public List<Issuelink> issuelinks { get; set; }
public object assignee { get; set; }
public Status2 status { get; set; }
public List<object> components { get; set; }
public object customfield_10730 { get; set; }
public object customfield_10600 { get; set; }
public object customfield_10601 { get; set; }
public object customfield_10602 { get; set; }
public object aggregatetimeestimate { get; set; }
public object customfield_10603 { get; set; }
public object customfield_10604 { get; set; }
public object customfield_10605 { get; set; }
public object customfield_10727 { get; set; }
public object customfield_10606 { get; set; }
public object customfield_10728 { get; set; }
public object customfield_10607 { get; set; }
public object customfield_10608 { get; set; }
public object customfield_10729 { get; set; }
public object customfield_10609 { get; set; }
public Creator creator { get; set; }
public List<object> subtasks { get; set; }
public Reporter reporter { get; set; }
public Aggregateprogress aggregateprogress { get; set; }
public object customfield_10711 { get; set; }
public object customfield_10712 { get; set; }
public List<ClosedSprint> closedSprints { get; set; }
public Progress progress { get; set; }
public Votes votes { get; set; }
public Worklog worklog { get; set; }
public Issuetype2 issuetype { get; set; }
public object timespent { get; set; }
public Sprint sprint { get; set; }
public Project project { get; set; }
public object aggregatetimespent { get; set; }
public object resolutiondate { get; set; }
public int workratio { get; set; }
public Watches watches { get; set; }
public DateTime created { get; set; }
public object customfield_10300 { get; set; }
public object customfield_10301 { get; set; }
public DateTime updated { get; set; }
public object timeoriginalestimate { get; set; }
public string description { get; set; }
public Timetracking timetracking { get; set; }
public List<object> customfield_10401 { get; set; }
public object customfield_10402 { get; set; }
public string customfield_10006 { get; set; }
public object customfield_10403 { get; set; }
public object security { get; set; }
public object customfield_10007 { get; set; }
public List<object> attachment { get; set; }
public bool flagged { get; set; }
public string summary { get; set; }
public string customfield_10000 { get; set; }
public object customfield_10001 { get; set; }
public object customfield_10002 { get; set; }
public object customfield_10400 { get; set; }
public object environment { get; set; }
public object duedate { get; set; }
public Comment comment { get; set; }
}
public class RootObject
{
public string expand { get; set; }
public string id { get; set; }
public string self { get; set; }
public string key { get; set; }
public Fields fields { get; set; }
}
现在您只需删除您不需要的所有内容(如果需要,可以重命名类名)。完成后,您将拥有可以使用的课程。
以下类只会存储初始&#34;键&#34;价值和&#34;名称&#34;您在帖子中要求的状态。
public class Status
{
public string Name { get; set; }
}
public class Fields2
{
public Status Status { get; set; }
}
public class InwardIssue
{
public Fields2 Fields { get; set; }
}
public class Issuelink
{
public InwardIssue InwardIssue { get; set; }
}
public class Fields
{
public List<Issuelink> Issuelinks { get; set; }
}
public class RootObject
{
public string Key { get; set; }
public Fields Fields { get; set; }
}
要反序列化您的json,您现在可以使用以下代码:
string content = //your json
RootObject ro = Newtonsoft.Json.JsonConvert.DeserializeObject<RootObject>(content);
如果某些事情仍然存在问题,那么请写下来,我会尝试解决问题。
答案 1 :(得分:0)
费边,
下面是我将整个JSON字符串放入网站后,您提供的网站生成的类。
for .. in ...
}
我认为我宁愿拥有太多的课程并让它工作,然后我可以彻底清除我之后不需要的东西(可能会考虑使用其他属性来生成其他图形等)。下面是我正在尝试的代码。我尝试过其他一些变体,但我仍然遇到同样的意外字符错误。
public class I18nErrorMessage
{
public string i18nKey { get; set; }
public List<object> parameters { get; set; }
}
public class Customfield10502
{
public string errorMessage { get; set; }
public I18nErrorMessage i18nErrorMessage { get; set; }
}
public class I18nErrorMessage2
{
public string i18nKey { get; set; }
public List<object> parameters { get; set; }
}
public class Customfield10503
{
public string errorMessage { get; set; }
public I18nErrorMessage2 i18nErrorMessage { get; set; }
}
public class Color
{
public string key { get; set; }
}
public class Epic
{
public int id { get; set; }
public string key { get; set; }
public string self { get; set; }
public string name { get; set; }
public string summary { get; set; }
public Color color { get; set; }
public bool done { get; set; }
}
public class Priority
{
public string self { get; set; }
public string iconUrl { get; set; }
public string name { get; set; }
public string id { get; set; }
}
public class I18nErrorMessage3
{
public string i18nKey { get; set; }
public List<object> parameters { get; set; }
}
public class Customfield10616
{
public string errorMessage { get; set; }
public I18nErrorMessage3 i18nErrorMessage { get; set; }
}
public class AvatarUrls
{
public string __invalid_name__48x48 { get; set; }
public string __invalid_name__24x24 { get; set; }
public string __invalid_name__16x16 { get; set; }
public string __invalid_name__32x32 { get; set; }
}
public class Assignee
{
public string self { get; set; }
public string name { get; set; }
public string key { get; set; }
public string accountId { get; set; }
public string emailAddress { get; set; }
public AvatarUrls avatarUrls { get; set; }
public string displayName { get; set; }
public bool active { get; set; }
public string timeZone { get; set; }
}
public class StatusCategory
{
public string self { get; set; }
public int id { get; set; }
public string key { get; set; }
public string colorName { get; set; }
public string name { get; set; }
}
public class Status
{
public string self { get; set; }
public string description { get; set; }
public string iconUrl { get; set; }
public string name { get; set; }
public string id { get; set; }
public StatusCategory statusCategory { get; set; }
}
public class AvatarUrls2
{
public string __invalid_name__48x48 { get; set; }
public string __invalid_name__24x24 { get; set; }
public string __invalid_name__16x16 { get; set; }
public string __invalid_name__32x32 { get; set; }
}
public class Creator
{
public string self { get; set; }
public string name { get; set; }
public string key { get; set; }
public string accountId { get; set; }
public string emailAddress { get; set; }
public AvatarUrls2 avatarUrls { get; set; }
public string displayName { get; set; }
public bool active { get; set; }
public string timeZone { get; set; }
}
public class AvatarUrls3
{
public string __invalid_name__48x48 { get; set; }
public string __invalid_name__24x24 { get; set; }
public string __invalid_name__16x16 { get; set; }
public string __invalid_name__32x32 { get; set; }
}
public class Reporter
{
public string self { get; set; }
public string name { get; set; }
public string key { get; set; }
public string accountId { get; set; }
public string emailAddress { get; set; }
public AvatarUrls3 avatarUrls { get; set; }
public string displayName { get; set; }
public bool active { get; set; }
public string timeZone { get; set; }
}
public class Aggregateprogress
{
public int progress { get; set; }
public int total { get; set; }
}
public class Customfield10711
{
public string self { get; set; }
public string value { get; set; }
public string id { get; set; }
}
public class AvatarUrls4
{
public string __invalid_name__48x48 { get; set; }
public string __invalid_name__24x24 { get; set; }
public string __invalid_name__16x16 { get; set; }
public string __invalid_name__32x32 { get; set; }
}
public class Customfield10712
{
public string self { get; set; }
public string name { get; set; }
public string key { get; set; }
public string accountId { get; set; }
public string emailAddress { get; set; }
public AvatarUrls4 avatarUrls { get; set; }
public string displayName { get; set; }
public bool active { get; set; }
public string timeZone { get; set; }
}
public class ClosedSprint
{
public int id { get; set; }
public string self { get; set; }
public string state { get; set; }
public string name { get; set; }
public DateTime startDate { get; set; }
public DateTime endDate { get; set; }
public DateTime completeDate { get; set; }
public int originBoardId { get; set; }
public string goal { get; set; }
}
public class Progress
{
public int progress { get; set; }
public int total { get; set; }
}
public class Votes
{
public string self { get; set; }
public int votes { get; set; }
public bool hasVoted { get; set; }
}
public class Worklog
{
public int startAt { get; set; }
public int maxResults { get; set; }
public int total { get; set; }
public List<object> worklogs { get; set; }
}
public class Issuetype
{
public string self { get; set; }
public string id { get; set; }
public string description { get; set; }
public string iconUrl { get; set; }
public string name { get; set; }
public bool subtask { get; set; }
public int avatarId { get; set; }
}
public class Sprint
{
public int id { get; set; }
public string self { get; set; }
public string state { get; set; }
public string name { get; set; }
public DateTime startDate { get; set; }
public DateTime endDate { get; set; }
public int originBoardId { get; set; }
public string goal { get; set; }
}
public class AvatarUrls5
{
public string __invalid_name__48x48 { get; set; }
public string __invalid_name__24x24 { get; set; }
public string __invalid_name__16x16 { get; set; }
public string __invalid_name__32x32 { get; set; }
}
public class Project
{
public string self { get; set; }
public string id { get; set; }
public string key { get; set; }
public string name { get; set; }
public string projectTypeKey { get; set; }
public AvatarUrls5 avatarUrls { get; set; }
}
public class Watches
{
public string self { get; set; }
public int watchCount { get; set; }
public bool isWatching { get; set; }
}
public class Timetracking
{
}
public class I18nErrorMessage4
{
public string i18nKey { get; set; }
public List<object> parameters { get; set; }
}
public class Customfield10400
{
public string errorMessage { get; set; }
public I18nErrorMessage4 i18nErrorMessage { get; set; }
}
public class Comment
{
public List<object> comments { get; set; }
public int maxResults { get; set; }
public int total { get; set; }
public int startAt { get; set; }
}
public class StatusCategory2
{
public string self { get; set; }
public int id { get; set; }
public string key { get; set; }
public string colorName { get; set; }
public string name { get; set; }
}
public class Status2
{
public string self { get; set; }
public string description { get; set; }
public string iconUrl { get; set; }
public string name { get; set; }
public string id { get; set; }
public StatusCategory2 statusCategory { get; set; }
}
public class Priority2
{
public string self { get; set; }
public string iconUrl { get; set; }
public string name { get; set; }
public string id { get; set; }
}
public class Issuetype2
{
public string self { get; set; }
public string id { get; set; }
public string description { get; set; }
public string iconUrl { get; set; }
public string name { get; set; }
public bool subtask { get; set; }
public int avatarId { get; set; }
}
public class Fields2
{
public string summary { get; set; }
public Status2 status { get; set; }
public Priority2 priority { get; set; }
public Issuetype2 issuetype { get; set; }
}
public class Parent
{
public string id { get; set; }
public string key { get; set; }
public string self { get; set; }
public Fields2 fields { get; set; }
}
public class Fields
{
public List<object> fixVersions { get; set; }
public object customfield_10110 { get; set; }
public object customfield_10111 { get; set; }
public object resolution { get; set; }
public object customfield_10112 { get; set; }
public List<string> customfield_10113 { get; set; }
public string customfield_10114 { get; set; }
public object customfield_10104 { get; set; }
public object customfield_10500 { get; set; }
public object customfield_10501 { get; set; }
public object customfield_10105 { get; set; }
public object customfield_10106 { get; set; }
public Customfield10502 customfield_10502 { get; set; }
public Customfield10503 customfield_10503 { get; set; }
public object customfield_10107 { get; set; }
public object customfield_10108 { get; set; }
public object customfield_10109 { get; set; }
public object lastViewed { get; set; }
public Epic epic { get; set; }
public Priority priority { get; set; }
public DateTime? customfield_10100 { get; set; }
public object customfield_10101 { get; set; }
public object customfield_10102 { get; set; }
public List<object> labels { get; set; }
public object customfield_10103 { get; set; }
public object customfield_10731 { get; set; }
public object customfield_10610 { get; set; }
public object customfield_10611 { get; set; }
public object customfield_10612 { get; set; }
public string customfield_10733 { get; set; }
public object customfield_10613 { get; set; }
public object timeestimate { get; set; }
public object customfield_10614 { get; set; }
public object aggregatetimeoriginalestimate { get; set; }
public DateTime? customfield_10735 { get; set; }
public List<object> versions { get; set; }
public object customfield_10615 { get; set; }
public Customfield10616 customfield_10616 { get; set; }
public object customfield_10617 { get; set; }
public List<object> issuelinks { get; set; }
public Assignee assignee { get; set; }
public Status status { get; set; }
public List<object> components { get; set; }
public object customfield_10730 { get; set; }
public object customfield_10600 { get; set; }
public object customfield_10601 { get; set; }
public object customfield_10602 { get; set; }
public object customfield_10603 { get; set; }
public object aggregatetimeestimate { get; set; }
public object customfield_10604 { get; set; }
public object customfield_10605 { get; set; }
public object customfield_10606 { get; set; }
public object customfield_10727 { get; set; }
public object customfield_10728 { get; set; }
public object customfield_10607 { get; set; }
public object customfield_10608 { get; set; }
public object customfield_10729 { get; set; }
public object customfield_10609 { get; set; }
public Creator creator { get; set; }
public List<object> subtasks { get; set; }
public Reporter reporter { get; set; }
public Aggregateprogress aggregateprogress { get; set; }
public Customfield10711 customfield_10711 { get; set; }
public Customfield10712 customfield_10712 { get; set; }
public List<ClosedSprint> closedSprints { get; set; }
public Progress progress { get; set; }
public Votes votes { get; set; }
public Worklog worklog { get; set; }
public Issuetype issuetype { get; set; }
public object timespent { get; set; }
public Sprint sprint { get; set; }
public Project project { get; set; }
public object aggregatetimespent { get; set; }
public object resolutiondate { get; set; }
public int workratio { get; set; }
public Watches watches { get; set; }
public DateTime created { get; set; }
public object customfield_10300 { get; set; }
public object customfield_10301 { get; set; }
public DateTime updated { get; set; }
public object timeoriginalestimate { get; set; }
public string description { get; set; }
public Timetracking timetracking { get; set; }
public List<object> customfield_10401 { get; set; }
public object customfield_10402 { get; set; }
public string customfield_10006 { get; set; }
public object customfield_10403 { get; set; }
public object security { get; set; }
public object customfield_10007 { get; set; }
public List<object> attachment { get; set; }
public bool flagged { get; set; }
public string summary { get; set; }
public string customfield_10000 { get; set; }
public object customfield_10001 { get; set; }
public object customfield_10002 { get; set; }
public Customfield10400 customfield_10400 { get; set; }
public object environment { get; set; }
public object duedate { get; set; }
public Comment comment { get; set; }
public string customfield_10710 { get; set; }
public Parent parent { get; set; }
}
public class Issue
{
public string expand { get; set; }
public string id { get; set; }
public string self { get; set; }
public string key { get; set; }
public Fields fields { get; set; }
}
public class RootObject
{
public string expand { get; set; }
public int startAt { get; set; }
public int maxResults { get; set; }
public int total { get; set; }
public List<Issue> issues { get; set; }
}