|
43 | 43 | import jakarta.json.stream.JsonParser.Event; |
44 | 44 | import jakarta.json.stream.JsonParsingException; |
45 | 45 | import java.io.StringReader; |
| 46 | +import java.math.BigDecimal; |
| 47 | +import java.math.BigInteger; |
46 | 48 | import java.util.AbstractMap; |
47 | 49 | import java.util.Map; |
48 | 50 | import java.util.stream.Collectors; |
@@ -78,11 +80,31 @@ public JsonProvider jsonProvider() { |
78 | 80 | public <T> void serialize(T value, JsonGenerator generator) { |
79 | 81 | if (value instanceof JsonpSerializable) { |
80 | 82 | ((JsonpSerializable) value).serialize(generator, this); |
81 | | - return; |
| 83 | + } else if (value instanceof JsonValue) { |
| 84 | + generator.write((JsonValue) value); |
| 85 | + } else if (value instanceof String) { |
| 86 | + generator.write((String) value); |
| 87 | + } else if (value instanceof BigDecimal) { |
| 88 | + generator.write((BigDecimal) value); |
| 89 | + } else if (value instanceof BigInteger) { |
| 90 | + generator.write((BigInteger) value); |
| 91 | + } else if (value instanceof Short) { |
| 92 | + generator.write((Short) value); |
| 93 | + } else if (value instanceof Integer) { |
| 94 | + generator.write((Integer) value); |
| 95 | + } else if (value instanceof Long) { |
| 96 | + generator.write((Long) value); |
| 97 | + } else if (value instanceof Float) { |
| 98 | + generator.write((Float) value); |
| 99 | + } else if (value instanceof Double) { |
| 100 | + generator.write((Double) value); |
| 101 | + } else if (value instanceof Boolean) { |
| 102 | + generator.write((Boolean) value); |
| 103 | + } else { |
| 104 | + throw new JsonException( |
| 105 | + "Cannot find a serializer for type " + value.getClass().getName() + ". Consider using a full-featured JsonpMapper." |
| 106 | + ); |
82 | 107 | } |
83 | | - throw new JsonException( |
84 | | - "Cannot find a serializer for type " + value.getClass().getName() + ". Consider using a full-featured JsonpMapper." |
85 | | - ); |
86 | 108 | } |
87 | 109 |
|
88 | 110 | @Override |
|
0 commit comments