3. If all else fails, `JsonDeserializer` uses the static type of the attribute,
or the type name passed to `deserialize`.
-The method `from_json_string` is a shortcut to `JsonDeserializer` which prints
+The method `deserialize_json` is a shortcut to `JsonDeserializer` which prints
errors to the console. It is fit only for small scripts and other quick and dirty usage.
### Example
# See the License for the specific language governing permissions and
# limitations under the License.
-# Services to read JSON: `from_json_string` and `JsonDeserializer`
+# Services to read JSON: `deserialize_json` and `JsonDeserializer`
module serialization_read
import serialization::caching
# 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 from_json_string: nullable Object
+ fun deserialize_json(static_type: nullable String): nullable Object
do
var deserializer = new JsonDeserializer(self)
- var res = deserializer.deserialize
+ var res = deserializer.deserialize(static_type)
if deserializer.errors.not_empty then
print_error "Deserialization Errors: {deserializer.errors.join(", ")}"
end