I am trying to convert an Issue object into JSON, but it was giving me a Stack Overflow error.
I tried to solution proposed here:
And tried to convert my IssueBean into a JSON object using com.google.gson.Gson.
I am creating my IssueBean this way:
URI selfUri = URI.create("");
IssueBean bean = new IssueBean(issue.getId(), issue.getKey(), selfUri);
then I use the code in the example above to populate it, and finally I use gson to convert it to Json.
Gson gson = new Gson();
gson.toJson(object); // Throws a null exception.
It gives me a null pointer exception for some reason. I tried to have my own class, containing a HashMap<String, Object> and adding the fields ids as key and FieldJsonRepresentation as value, but it is giving me the same null pointer exception. If I add manually a random key-value set in my map, it works…
What can I go to return an issue in JSON format without errors?
I tried using Jackson instead, and that works, but there is no “rendered fields” values in my IssueBean.
ObjectMapper mapper = new com.atlassian.adapter.jackson.ObjectMapper();
I also tried to use the IssueBeanBuilder with those two ways.
//IncludedFields is giving a correct value, issue is a correct value.
IssueBeanBuilder bb = new IssueBeanBuilder(this.beanBuilderFactory, IncludedFields.includeAllByDefault((List)null), issue);
IssueBean bean = bb.expand(“names,renderedFields”).build(); // Throws a null exception
IssueBeanBuilder2 bb2 = this.beanBuilderFactory.newIssueBeanBuilder2(IncludedFields.includeAllByDefault((List) null), “names,renderedFields”); // Throws a null exception
IssueBean bean = bb2.build(issue);