Skip to content

Commit

Permalink
add JsonDataImpl serialize value type
Browse files Browse the repository at this point in the history
Signed-off-by: Leo <[email protected]>
  • Loading branch information
Leo committed Nov 23, 2024
1 parent ee4d373 commit fae2c65
Showing 1 changed file with 14 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@
import jakarta.json.stream.JsonParser;
import java.io.StringReader;
import java.io.StringWriter;
import java.math.BigDecimal;
import java.math.BigInteger;

class JsonDataImpl implements JsonData {
private final Object value;
Expand Down Expand Up @@ -111,10 +113,22 @@ public void serialize(JsonGenerator generator, JsonpMapper mapper) {
generator.write((JsonValue) value);
} else if (value instanceof String) {
generator.write((String) value);
} else if (value instanceof BigDecimal) {
generator.write((BigDecimal) value);
} else if (value instanceof BigInteger) {
generator.write((BigInteger) value);
} else if (value instanceof Short) {
generator.write((Short) value);
} else if (value instanceof Integer) {
generator.write((Integer) value);
} else if (value instanceof Long) {
generator.write((Long) value);
} else if (value instanceof Float) {
generator.write((Float) value);
} else if (value instanceof Double) {
generator.write((Double) value);
} else if (value instanceof Boolean) {
generator.write((Boolean) value);
} else {
// Mapper provided at creation time has precedence
(this.mapper != null ? this.mapper : mapper).serialize(value, generator);
Expand Down

0 comments on commit fae2c65

Please sign in to comment.