You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have an API that I'm dealing with that will return nulls encoded as a string "null", for example:
data model:
@Serializable
data classNullableString(valvalue:String? = null)
or
@Serializable
data classNullableOtherClass(valvalue:OtherSerializableObject? = null)
and in either case, the API may return
{"value": "null"}
Is there a way to provide a custom nullable serializer that will allow me to handle these myself? Just for strings, or for all object types?
If so, is there a way to register this serializer to work with all Any? fields, rather than having to apply an annotation for every field?
If there is a solution for both 1&2, I'm good, however, if there is not, then I've got a problem (several thousand fields and growing in the data model for the API I'm dealing with).
I understand that this used to throw an error in lenient mode (#1600), and that making this the default behavior wouldn't be ideal for all use cases (e.g., German), but I would like to see a setting that perhaps works in conjunction with lenient mode, something like:
Json{ isLenient=true; unboxNullStrings =true }
Turning on that setting, if lenient mode is enabled, should allow:
null
"null"
'null'
to all be treated as NULL for any nullable field during deserialization.
The text was updated successfully, but these errors were encountered:
I have an API that I'm dealing with that will return nulls encoded as a string "null", for example:
data model:
or
and in either case, the API may return
If there is a solution for both 1&2, I'm good, however, if there is not, then I've got a problem (several thousand fields and growing in the data model for the API I'm dealing with).
I understand that this used to throw an error in lenient mode (#1600), and that making this the default behavior wouldn't be ideal for all use cases (e.g., German), but I would like to see a setting that perhaps works in conjunction with lenient mode, something like:
Turning on that setting, if lenient mode is enabled, should allow:
to all be treated as NULL for any nullable field during deserialization.
The text was updated successfully, but these errors were encountered: