There’s a project use Jackson, and have a Java object Data. In the object, there’s a property, and it’s also a object Raw. In this object,there’s a property List<Object[]>
e.g:
public class Data{
Raw raw;
}
public class Raw{
List<Object[]> list;
}
If the Object[] have a data type: long, and I give a value: 123, then the Jackson will convert this data type to int,
i.e: If the value’s length < long && > int , the data type is also long, if length < int, the data type will become int.
I use the method:
byte[] bytes = writeValueAsBytes(Data), Data data = readValue(bytes, Data.class)
How could I keep the original data type when it is converted?
Jackson does what I think you want:
However
numberswill not equalnewNumbersbecause100Lshould be an integer.The maximum number that JSON can handle is a 64 bit double precision.
If your doing data serialization like for binary images then I would encode the data in Base64.