quarkusio/quarkus · error · IllegalStateException
Unsupported value type: ${value}
Error message
Unsupported value type: ${value} What it means
Json.toJsonString (appendValue path) only knows how to serialize String, Boolean, Integer, and Long values. When a JsonValue holds any other type (e.g. Double, Float, BigDecimal, byte[]), the writer cannot map it to JSON and throws IllegalStateException. It is a programming error indicating an unsupported value was stored in the JSON model.
Source
Thrown at independent-projects/bootstrap/json/src/main/java/io/quarkus/bootstrap/json/Json.java:541
if (!objectBuilder.isEmpty()) {
put(attribute, objectBuilder);
}
}
}
}
}
static void appendValue(Appendable appendable, Object value) throws IOException {
if (value instanceof JsonObjectBuilder jsonObj) {
jsonObj.appendTo(appendable);
} else if (value instanceof JsonArrayBuilder jsonArr) {
jsonArr.appendTo(appendable);
} else if (value instanceof String str) {
appendStringValue(appendable, str);
} else if (value instanceof Boolean || value instanceof Integer || value instanceof Long) {
appendable.append(value.toString());
} else {
throw new IllegalStateException("Unsupported value type: " + value);
}
}
static void appendStringValue(Appendable appendable, String value) throws IOException {
appendable.append(CHAR_QUOTATION_MARK);
appendEscaped(appendable, value);
appendable.append(CHAR_QUOTATION_MARK);
}
/**
* Escape quotation mark, reverse solidus and control characters (U+0000 through U+001F).
*
* @param value value to escape
* @see <a href="https://www.ietf.org/rfc/rfc4627.txt">https://www.ietf.org/rfc/rfc4627.txt</a>
*/
static void appendEscaped(Appendable appendable, String value) throws IOException {
for (int i = 0; i < value.length(); i++) {
final char c = value.charAt(i);View on GitHub (pinned to e1c734241f)
Solutions
- Convert the value to a supported type before storing, e.g. use value.toString() for decimals or store as String
- Extend/patch the writer to handle the type you need, or pre-serialize custom objects into a JSON string
- Inspect the value reported in the message and find where it was inserted into the Json model
Example fix
// before
json.set("price", 19.99d);
// after
json.set("price", "19.99"); Defensive patterns
Strategy: type-guard
Validate before calling
static boolean isJsonSerializable(Object v) {
return v instanceof String || v instanceof Boolean || v instanceof Integer || v instanceof Long;
}
// assert isJsonSerializable(value) before json.set(...) Type guard
static boolean isSupportedJsonValue(Object v) {
return v instanceof String || v instanceof Boolean || v instanceof Integer || v instanceof Long;
} Try / catch
try {
String json = Json.toJsonString(value);
} catch (IllegalStateException e) {
if (e.getMessage().startsWith("Unsupported value type")) {
// fall back to String.valueOf(value) or a custom serializer
}
} Prevention
- Only store String, Boolean, Integer, or Long in hand-built Json models
- Convert doubles/decimals to String (or a supported type) before insertion
- Add an assertion or unit test asserting every inserted value passes a supported-type check
When it happens
Trigger: Building a Json object/array programmatically and putting a value type outside {String, Boolean, Integer, Long} (e.g. Double, Float, BigDecimal), then serializing it with Json's public write method.
Common situations: Storing parsed numeric values like doubles or decimals into a Json model built by hand; mixing java.util types with the model; upgrading code that previously only stored strings/ints.
Related errors
- Unknown JSON Value
- Failed to encode as JSON:
- Json array ended without ]
- Control characters not allowed in json string
- String not closed
AI-assisted analysis of quarkusio/quarkus@e1c734241f (2026-09-05).
Data as JSON: /api/errors/35dafa9d1856571a.
Report an issue: GitHub.