Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [leshan-dev] LwM2mNodeDeserializer.java JSON parser error

Great..

Thank you.

 

From: leshan-dev-bounces@xxxxxxxxxxx [mailto:leshan-dev-bounces@xxxxxxxxxxx] On Behalf Of Simon Bernard
Sent: Wednesday, March 11, 2015 12:11 PM
To: leshan developer discussions
Subject: Re: [leshan-dev] LwM2mNodeDeserializer.java JSON parser error

 

In fact, the problem was deeper than that. We didn't support the OPAQUE format before.
All of this should be fixed now :
https://github.com/eclipse/leshan/commit/aa02658f4573de0a018c63816d8d33baef1dad87
https://github.com/eclipse/leshan/commit/c8dd5c829eaef00bb36961691249cdfe3d066c97
This will be integrated in the next milestone, which should be released before the end of the week.

Simon

Le 10/03/2015 17:45, Simon Bernard a écrit :

Hi,
 You're right this is a problem.
 I don't know what is the best think to do. Currently we serialyze an OPAQUE value as a byte array.
 You propose to fix the problem at deserialization, but maybe this could be better to serialyse OPAQUE value as an Hexadecimal string ?
Simon
 

Le 04/03/2015 23:36, Alseddeg Nizar a écrit :

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…!


This message and any attachments are intended solely for the addressees and may contain confidential information. Any unauthorized use or disclosure, either whole or partial, is prohibited.
E-mails are susceptible to alteration. Our company shall not be liable for the message if altered, changed or falsified. If you are not the intended recipient of this message, please delete it and notify the sender.
Although all reasonable efforts have been made to keep this transmission free from viruses, the sender will not be liable for damages caused by a transmitted virus.



_______________________________________________
leshan-dev mailing list
leshan-dev@xxxxxxxxxxx
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://dev.eclipse.org/mailman/listinfo/leshan-dev





_______________________________________________
leshan-dev mailing list
leshan-dev@xxxxxxxxxxx
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://dev.eclipse.org/mailman/listinfo/leshan-dev

 


This message and any attachments are intended solely for the addressees and may contain confidential information. Any unauthorized use or disclosure, either whole or partial, is prohibited.
E-mails are susceptible to alteration. Our company shall not be liable for the message if altered, changed or falsified. If you are not the intended recipient of this message, please delete it and notify the sender.
Although all reasonable efforts have been made to keep this transmission free from viruses, the sender will not be liable for damages caused by a transmitted virus.

Back to the top