Sprint field value REST API

Maarten Cautreels Community Champion Aug 25, 2013

When trying to get the details of an issue through the REST API the response for the Sprint looks something like this:

  • customfield_10007:[
    • "com.atlassian.greenhopper.service.sprint.Sprint@a29f07[rapidViewId=<null>,state=CLOSED,name=NORD - Sprint 42,startDate=2013-07-29T06:47:00.000+02:00,endDate=2013-08-11T20:47:00.000+02:00,completeDate=2013-08-14T15:31:33.157+02:00,id=107]",
    • "com.atlassian.greenhopper.service.sprint.Sprint@769133[rapidViewId=<null>,state=ACTIVE,name=NORD - Sprint 43,startDate=2013-08-14T15:32:47.322+02:00,endDate=2013-08-23T15:32:47.322+02:00,completeDate=<null>,id=117]"

It looks like toString of the Sprint class which isn't very easy to parse/read with an application. Is their a way to simple get the Sprint Name or id returned through the REST API. It's necessary to be able to retrieve the Sprint value in an internal tool for our QA Team (Spira Test).

On the other side, using toString in the REST API output doesn't seem like a good idea to me ...



6 answers

1 accepted

1 vote
Maarten Cautreels Community Champion Sep 11, 2013

No Answer has been found :-(

Any idea of one jar containing the mentioned class com.atlassian.greenhopper.service.sprint.Sprint
I assume the response can be parsed something like the following:

Field field = issue.getFieldByName("Sprint");
JSONArray fieldValue = (JSONArray) field.getValue();
com.atlassian.greenhopper.service.sprint.Sprint sprint = (Sprint) fieldValue.get(0);

I just can't find the particular class/jar.

Found it, but it looks too big to include, I think I'll go with parsing it as a String.

Jar info can be found at https://www.versioneye.com/java/com.atlassian.jira.plugins:jira-greenhopper-plugin/6.2

1 vote

I was having the same issue for a small tool I was developing in which I needed the sprint name. Since I was using Jackson to unmarshal my JIRA response, I ended up writing a custom deserializer: 

import com.fasterxml.jackson.core.JsonParser;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.DeserializationContext;
import com.fasterxml.jackson.databind.JsonDeserializer;

import java.io.IOException;
import java.util.Collection;
import java.util.HashMap;
import java.util.Map;
import java.util.function.Function;

import static java.util.stream.Collectors.toList;

public class SprintNamesExtractingDeserializer extends JsonDeserializer<Collection> {

private static final String OPEN_ARRAY_CHARACTER = "\\[";
private static final String CLOSE_ARRAY_CHARACTER = "]";
private static final String COMMA = ",";
private static final String EQUALS_SIGN = "=";
private static final String NAME_PROPERTY = "name";

public SprintNamesExtractingDeserializer() {

public Collection deserialize(final JsonParser jsonParser, final DeserializationContext deserializationContext) throws IOException, JsonProcessingException {
TypeReference<Collection<String>> typedCollection = new TypeReference<Collection<String>>() {
Collection<String> sprints = jsonParser.readValueAs(typedCollection);
return sprints.stream()

private Function<String, String> extractSprintName() {
return sprintString -> {
String result = sprintString.split(OPEN_ARRAY_CHARACTER, 2)[1];
Map<String, String> sprintProperties = extractSprintProperties(result);

return sprintProperties.getOrDefault(NAME_PROPERTY, null);

private Map<String, String> extractSprintProperties(String result) {
int lastArrayClosure = result.lastIndexOf(CLOSE_ARRAY_CHARACTER);
result = result.substring(0, lastArrayClosure);
String[] propertiesArray = result.split(COMMA);
HashMap<String, String> properties = new HashMap<>();
for (String property: propertiesArray) {
String[] keyValueArray = property.split(EQUALS_SIGN);
if (keyValueArray.length == 1) {
properties.put(keyValueArray[0], null);
} else if (keyValueArray.length == 2) {
properties.put(keyValueArray[0], keyValueArray[1]);
// Else it's not a valid property
return properties;


Which can be used as: 

@JsonDeserialize(using = SprintNamesExtractingDeserializer.class, as=Collection.class)
public abstract Collection<String> getSprintNames();

 I'm not particularly proud of this solution, but it does the trick. 

0 vote
Timothy Chin Community Champion Aug 25, 2013

It's not hard to parse that. The toString returns a JSON representation of that object. You just need to convert that String into a JSON object.

Maarten Cautreels Community Champion Sep 01, 2013

It's far from JSON ...

JSON would be something like this:

	rapidViewId: 1,
	state: "Closed",
	name: "NORD - Sprint 42",

[ignore]Double-post because of spam filter not letting through my code example.[/ignore] 

Suggest an answer

Log in or Join to answer
Community showcase
Sarah Schuster
Posted Jan 29, 2018 in Jira

What are common themes you've seen across successful & failed Jira Software implementations?

Hey everyone! My name is Sarah Schuster, and I'm a Customer Success Manager in Atlassian specializing in Jira Software Cloud. Over the next few weeks I will be posting discussion topics (8 total) to ...

3,319 views 14 20
Join discussion

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you
Atlassian Team Tour

Join us on the Team Tour

We're bringing product updates and pro tips on teamwork to ten cities around the world.

Save your spot