1 Reply Latest reply on May 6, 2009 4:14 AM by timfox

    JSON serialization issues

    jmesnil

      I've encountered several issues with JSON serialization yesterday:

      - int and long are decoded as Integer when using JSONObject.get(key) method
      => ClassCastException when the code is expecting a long and receives a integer

      - String[] parameters are deserialized as Object[]
      => All the createConnectionFactory() methods don't work: the ManagementService will not find the matching method since Object[] and String[] are different types (and not assignable).
      I've hacked 1 createConnectionFactory method to pass the parameters as Object[] to run the JORAM tests but all the others methods won't work.

        • 1. Re: JSON serialization issues
          timfox

           

          "jmesnil" wrote:
          I've encountered several issues with JSON serialization yesterday:

          - int and long are decoded as Integer when using JSONObject.get(key) method
          => ClassCastException when the code is expecting a long and receives a integer


          Internally JSON does not distinguish an int and a long (it's just a numeric string).

          However when decoding if the number is too large to fit in a Java int it will use a long I believe, otherwise it will use an int.

          So you should be ok just to cast. BTW I already did this in CoreMessagingProxy.


          - String[] parameters are deserialized as Object[]
          => All the createConnectionFactory() methods don't work: the ManagementService will not find the matching method since Object[] and String[] are different types (and not assignable).
          I've hacked 1 createConnectionFactory method to pass the parameters as Object[] to run the JORAM tests but all the others methods won't work.



          So change the params to Object[] ?...