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

    JSON serialization issues

    Jeff Mesnil Master

      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
          Tim Fox Master

           

          "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[] ?...