Hello, It has been a quite long from
Leshan.. got swapped to different tasks in the past few weeks,
back to it again
J
Â
While testing a client, I came across this
issue ( Julien I think I did mention this issue to you in the
testFest Dusseldorf, not sure if you still remember).
Â
I think itâs a bug and it happen in the
case of a client response contain OPAQUE Value, see the
example below in
RED..
Use Case:
Location object, resource Velocity  id â4â
 type is OPAQUE ..
 MESSAGE =
{"id":0,"resources":[{"id":0,"value":"test"},{"id":1,"value":"test"},{"id":2,"value":"test"},{"id":4,"value":[39,39]},{"id":5,"value":"1970-01-01T00:00:00Z"}]}
Â
Â
The code failed because of the if
condition in
org.eclipse.leshan.standalone.servlet.json.LwM2mNodeDeserializer.java line 75â¦
Â
 Â
}
else
if
(object.has("value"))
{
              Â
//
single value resource
     Â
/**
*
Donât you think if the type is Opaque
    Â
 * It should check if
if(object.get("value").isJsonArray())
    Â
 * In this case it loop through and deserializeValue
    Â
 */            Â
Â
Â
node =
new
LwM2mResource(id, this.deserializeValue(object.get("value").getAsJsonPrimitive()));
// Itâs an array not primitive thatâs why the error
thrown..
Â
}
else
if
(object.has("values"))
{
Â
Â
com.google.gson.JsonSyntaxException:
java.lang.IllegalStateException: This is not a JSON Primitive.
     at
com.google.gson.Gson.fromJson(Gson.java:815)
     at
com.google.gson.Gson.fromJson(Gson.java:868)
     at
com.google.gson.Gson$1.deserialize(Gson.java:126)
     at
org.eclipse.leshan.standalone.servlet.json.LwM2mNodeDeserializer.deserialize(LwM2mNodeDeserializer.java:77)
     at
org.eclipse.leshan.standalone.servlet.json.LwM2mNodeDeserializer.deserialize(LwM2mNodeDeserializer.java:50)
     at
com.google.gson.TreeTypeAdapter.read(TreeTypeAdapter.java:58)
Â
Â
Thanks,
Nizarâ¦!