문제

Anyway to create a Java POJO template from a JSON string? I'm using Jersey

{
  "reviewData" : [ {
    "projectKey" : "CR-FOO",
    "name" : "Example review.",
    "description" : "Description or statement of objectives for this example review.",
    "author" : {
      "userName" : "joe",
      "displayName" : "Joe Krustofski",
      "avatarUrl" : "http://foo.com/avatar"
    },
    "moderator" : {
      "userName" : "scott",
      "displayName" : "Scott the Moderator",
      "avatarUrl" : "http://foo.com/avatar"
    },
    "creator" : {
      "userName" : "joe",
      "displayName" : "Joe Krustofski",
      "avatarUrl" : "http://foo.com/avatar"
    },
    "permaId" : {
      "id" : "CR-FOO-21"
    },
    "permaIdHistory" : [ "CR-FOO-21" ],
    "type" : "REVIEW",
    "allowReviewersToJoin" : true,
    "metricsVersion" : 4,
    "createDate" : "2013-10-08T15:46:11.022+0200",
    "dueDate" : "2013-10-09T15:46:11.022+0200",
    "jiraIssueKey" : "FOO-6754"
  }, {
    "projectKey" : "CR-FOO",
    "name" : "Example review.",
    "description" : "Description or statement of objectives for this example review.",
    "author" : {
      "userName" : "joe",
      "displayName" : "Joe Krustofski",
      "avatarUrl" : "http://foo.com/avatar"
    },
    "moderator" : {
      "userName" : "scott",
      "displayName" : "Scott the Moderator",
      "avatarUrl" : "http://foo.com/avatar"
    },
    "creator" : {
      "userName" : "joe",
      "displayName" : "Joe Krustofski",
      "avatarUrl" : "http://foo.com/avatar"
    },
    "permaId" : {
      "id" : "CR-FOO-21"
    },
    "permaIdHistory" : [ "CR-FOO-21" ],
    "type" : "REVIEW",
    "allowReviewersToJoin" : true,
    "metricsVersion" : 4,
    "createDate" : "2013-10-08T15:46:11.022+0200",
    "dueDate" : "2013-10-09T15:46:11.022+0200",
    "jiraIssueKey" : "FOO-6754"
  } ]
}
도움이 되었습니까?

해결책

The best solution I found was http://www.jsonschema2pojo.org/

It has support for Jackson and Maven and an online tool as well.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top