exceptionsWithDebugInfo

Specifies whether actual input data should be included in exception messages.

When false, exception messages will not contain sensitive input data that could be logged or exposed in error reporting systems. This is the default and recommended setting for production environments where input data may contain sensitive or confidential information. With this setting disabled, JsonDecodingException.input will be null and JsonDecodingException.path will have <debug info disabled> where Map keys are supposed to be.

When true, exception messages will include the actual input data that caused the error, which can be helpful for debugging purposes during development.

While in experimental stage, this flag is true by default. It will be changed to false when API stabilizes to assume data is sensitive and unsafe by default.

Example of usage:

@Serializable
data class User(val name: String, val age: Int)

val json = Json { exceptionsWithDebugInfo = false }
// Exception message will not contain the invalid input string
json.decodeFromString<User>("""{"name":"John","age":"invalid"}""")

val debugJson = Json { exceptionsWithDebugInfo = true }
// Exception message will include `JSON Input: {"name":"John","age":"invalid"}` line
debugJson.decodeFromString<User>("""{"name":"John","age":"invalid"}""")