core :: Text :: deserialize_json
nullable Object
from this JSON formatted stringIf a static_type
is given, only subtypes of the static_type
are accepted.
Warning: Deserialization errors are reported with print_error
and
may be returned as a partial object or as null
.
This method is not appropriate when errors need to be handled programmatically,
manually use a JsonDeserializer
in such cases.
# Deserialize a `nullable Object` from this JSON formatted string
#
# If a `static_type` is given, only subtypes of the `static_type` are accepted.
#
# Warning: Deserialization errors are reported with `print_error` and
# may be returned as a partial object or as `null`.
#
# This method is not appropriate when errors need to be handled programmatically,
# manually use a `JsonDeserializer` in such cases.
fun deserialize_json(static_type: nullable String): nullable Object
do
var deserializer = new JsonDeserializer(self)
var res = deserializer.deserialize(static_type)
if deserializer.errors.not_empty then
print_error "Deserialization Errors: {deserializer.errors.join(", ")}"
end
return res
end
lib/json/serialization_read.nit:365,2--382,4