Hello,
I have a* class Service*
public class Service {
@NotNull
@ApiModelProperty("")
@XmlTransient
@AttributeInfo(
modifiable = "true"
)
public String name;
@Max(10)
@ApiModelProperty("")
@XmlTransient
@AttributeInfo(
modifiable = "true"
)
public Integer serviceID;
@JsonProperty("resource")
@Relationship(
type = "ASSOCIATES",
direction = "OUTGOING"
)
protected Set<Resource> resource = new HashSet<>();
:
:
}
And *class Resource*
public class Resource {
@Transient
@JsonIgnore
@XmlTransient
public String ref;
@GraphQLQuery(name = "ref")
@JsonIgnore
public String getRef() {
return ref;
}
@JsonProperty("@ref")
public void setRef(String ref) {
this.ref = ref;
}
@ApiModelProperty("")
@XmlTransient
@AttributeInfo(
modifiable = "true"
)
public String name;
@ApiModelProperty("")
@XmlTransient
@AttributeInfo(
modifiable = "true"
)
public String state;
@JsonProperty("service")
@Relationship(
type = "ASSOCIATES",
direction = "INCOMING"
)
protected Service service;
:
}
*BAD CASE*
When I create(POST) service object on http://localhost:8080/api/service
with payload
{
"name": "ServiceHOME",
"serviceID": "1",
"resource": [
{
"@ref": "/api/device/d581e0b8-eff0-4cff-ac45-6edb9292111e"
},
{
"@ref": "/api/device/17707856-e769-49b9-a2ae-97caf74a03a2"
}
]
}
The object created of service has only one resource object (with "@ref":
"/api/device/d581e0b8-eff0-4cff-ac45-6edb9292111e") created. The second
resource is missing completely.
*GOOD CASE*
Whereas, when I create(POST) service object on
http://localhost:8080/api/service with payload
{
"name": "ServiceHOME",
"serviceID": "1",
"resource": [
{
"@ref": "/api/device/d581e0b8-eff0-4cff-ac45-6edb9292111e"
},
{
"@ref": "/api/device/17707856-e769-49b9-a2ae-97caf74a03a2",
"name":"resourceName"
}
]
}
The object created of service has two resource object (with
"ref=/api/device/d581e0b8-eff0-4cff-ac45-6edb9292111e" and
"ref=/api/device/17707856-e769-49b9-a2ae-97caf74a03a2 + name=resourceName"
which is expected.
Even the below payload deserializes as expected (with three resource object
inside service object):
{
"name": "ServiceHOME",
"serviceID": "1",
"resource": [
{
"@ref": "/api/device/d581e0b8-eff0-4cff-ac45-6edb9292111e"
},
{
"@ref": "/api/device/17707856-e769-49b9-a2ae-97caf74a03a2",
"name":"resourceName"
},
{
"name":"resourceName"
}
]
}
I tried debugging the deserializeFromObject method in BeanDeserializer in
both good and bad cases and was able to see that bean is formed for two
resource object. But then I got lost on why in the bad case the 2nd
resource object was present in service object after deserialization.
Hitting the walls on trying to understand why did the bad case did not
deserialize as expected. Any ideas on what is going wrong?
Am using fasterxml 2.9.8 for jackson data binding and Spring boot version
is 2.1.3.
--
You received this message because you are subscribed to the Google Groups
"jackson-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/jackson-user/3ef1d89f-b680-4956-8750-7fd70abcbb14%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.