{"record":{"id":"35dafa9d1856571a","repo":"quarkusio/quarkus","slug":"unsupported-value-type-value","errorCode":null,"errorMessage":"Unsupported value type: ${value}","messagePattern":"Unsupported value type: (.+?)","errorType":"exception","errorClass":"IllegalStateException","httpStatus":null,"severity":"error","filePath":"independent-projects/bootstrap/json/src/main/java/io/quarkus/bootstrap/json/Json.java","lineNumber":541,"sourceCode":"                    if (!objectBuilder.isEmpty()) {\n                        put(attribute, objectBuilder);\n                    }\n                }\n            }\n        }\n    }\n\n    static void appendValue(Appendable appendable, Object value) throws IOException {\n        if (value instanceof JsonObjectBuilder jsonObj) {\n            jsonObj.appendTo(appendable);\n        } else if (value instanceof JsonArrayBuilder jsonArr) {\n            jsonArr.appendTo(appendable);\n        } else if (value instanceof String str) {\n            appendStringValue(appendable, str);\n        } else if (value instanceof Boolean || value instanceof Integer || value instanceof Long) {\n            appendable.append(value.toString());\n        } else {\n            throw new IllegalStateException(\"Unsupported value type: \" + value);\n        }\n    }\n\n    static void appendStringValue(Appendable appendable, String value) throws IOException {\n        appendable.append(CHAR_QUOTATION_MARK);\n        appendEscaped(appendable, value);\n        appendable.append(CHAR_QUOTATION_MARK);\n    }\n\n    /**\n     * Escape quotation mark, reverse solidus and control characters (U+0000 through U+001F).\n     *\n     * @param value value to escape\n     * @see <a href=\"https://www.ietf.org/rfc/rfc4627.txt\">https://www.ietf.org/rfc/rfc4627.txt</a>\n     */\n    static void appendEscaped(Appendable appendable, String value) throws IOException {\n        for (int i = 0; i < value.length(); i++) {\n            final char c = value.charAt(i);","sourceCodeStart":523,"sourceCodeEnd":559,"githubUrl":"https://github.com/quarkusio/quarkus/blob/e1c734241f34c7919086ceb4c9262b4a58f6de44/independent-projects/bootstrap/json/src/main/java/io/quarkus/bootstrap/json/Json.java#L523-L559","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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"],"exampleFix":"// before\njson.set(\"price\", 19.99d);\n// after\njson.set(\"price\", \"19.99\");","handlingStrategy":"type-guard","validationCode":"static boolean isJsonSerializable(Object v) {\n    return v instanceof String || v instanceof Boolean || v instanceof Integer || v instanceof Long;\n}\n// assert isJsonSerializable(value) before json.set(...)","typeGuard":"static boolean isSupportedJsonValue(Object v) {\n    return v instanceof String || v instanceof Boolean || v instanceof Integer || v instanceof Long;\n}","tryCatchPattern":"try {\n    String json = Json.toJsonString(value);\n} catch (IllegalStateException e) {\n    if (e.getMessage().startsWith(\"Unsupported value type\")) {\n        // fall back to String.valueOf(value) or a custom serializer\n    }\n}","preventionTips":["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"],"tags":["json","serialization","unsupported-type"],"backgroundTag":"unsupported-json-value-type","analyzedSha":"e1c734241f34c7919086ceb4c9262b4a58f6de44","analyzedAt":"2026-09-05T17:01:29.979Z","contentChangedAt":"2026-09-05T17:01:29.979Z","schemaVersion":2},"datasetVersion":"2026-09-12T22:17:10.623Z"}