diff --git a/src/main/java/org/springframework/hateoas/hal/Jackson2HalModule.java b/src/main/java/org/springframework/hateoas/hal/Jackson2HalModule.java index aa4f23c8..0f48ee3b 100644 --- a/src/main/java/org/springframework/hateoas/hal/Jackson2HalModule.java +++ b/src/main/java/org/springframework/hateoas/hal/Jackson2HalModule.java @@ -576,6 +576,7 @@ public class Jackson2HalModule extends SimpleModule { // links is an object, so we parse till we find its end. while (!JsonToken.END_OBJECT.equals(jp.nextToken())) { + if (!JsonToken.FIELD_NAME.equals(jp.getCurrentToken())) { throw new JsonParseException("Expected relation name", jp.getCurrentLocation()); } @@ -651,6 +652,7 @@ public class Jackson2HalModule extends SimpleModule { // links is an object, so we parse till we find its end. while (!JsonToken.END_OBJECT.equals(jp.nextToken())) { + if (!JsonToken.FIELD_NAME.equals(jp.getCurrentToken())) { throw new JsonParseException("Expected relation name", jp.getCurrentLocation()); } @@ -658,7 +660,6 @@ public class Jackson2HalModule extends SimpleModule { if (JsonToken.START_ARRAY.equals(jp.nextToken())) { while (!JsonToken.END_ARRAY.equals(jp.nextToken())) { object = deser.deserialize(jp, ctxt); - ; result.add(object); } } else { diff --git a/src/main/java/org/springframework/hateoas/hal/ResourcesMixin.java b/src/main/java/org/springframework/hateoas/hal/ResourcesMixin.java index 941ec600..7c4a1fbe 100644 --- a/src/main/java/org/springframework/hateoas/hal/ResourcesMixin.java +++ b/src/main/java/org/springframework/hateoas/hal/ResourcesMixin.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2013 the original author or authors. + * Copyright 2012-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -21,6 +21,8 @@ import javax.xml.bind.annotation.XmlElement; import org.springframework.hateoas.Resources; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonInclude.Include; import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonPropertyOrder; import com.fasterxml.jackson.databind.annotation.JsonDeserialize; @@ -32,8 +34,8 @@ public abstract class ResourcesMixin extends Resources { @Override @XmlElement(name = "embedded") @JsonProperty("_embedded") - @JsonSerialize(include = JsonSerialize.Inclusion.NON_EMPTY, using = Jackson2HalModule.HalResourcesSerializer.class) + @JsonInclude(Include.NON_EMPTY) + @JsonSerialize(using = Jackson2HalModule.HalResourcesSerializer.class) @JsonDeserialize(using = Jackson2HalModule.HalResourcesDeserializer.class) public abstract Collection getContent(); - }