I am using the flexjson api to serialize and deserialize a map using whole keys. Now, when deserializing, the card keys are converted to a string. Is there a way that keys can be stored as integers.
Here is a sample code
Map<Integer,Object> map = new HashMap<Integer, Object>(); map.put(1, "a"); map.put(2,"b"); flexjson.JSONSerializer serializer = new flexjson.JSONSerializer(); String serializedMapString = serializer.serialize(map); flexjson.JSONDeserializer<Map<Integer,Object>> deserializer = new flexjson.JSONDeserializer<Map<Integer,Object>>(); Map<Integer,Object> deserializedMap = deserializer.deserialize(serializedMapString); for(Integer key: deserializedMap.keySet()){ System.out.println(key+"-"+deserializedMap.get(key)); }
deserialization does not produce any errors, but the keys are converted to String.
source share