Is there any way to serialize BigInteger field in plain format as String JavaScript object field, rather than Numeric in exponential notation (which is default behavior of Jackson)?
Asked
Active
Viewed 6,838 times
2 Answers
3
You could use a specific serializer defined with JsonSerialize annotation
The problem is similar to this question:
-
2This solution is good in case you know the property type in compile time. In my case, I have a generic class that in some cases, one of its properties might be a BigInt and I want it to be serialized as a string. My question is, how do I replace the default BigInt serializer with one of my own? (the generic type might be a List
for example) – Modi Aug 13 '13 at 08:31
0
I assume this is the way:
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
...
@JsonSerialize(using = ToStringSerializer.class)
final private BigInteger serviceFee;

Klesun
- 12,280
- 5
- 59
- 52