class JRPCError extends Error { String message; JRPCError(this.message); @override String toString() => message; } int? int_fromJson(dynamic val) { if (val == null) { return null; } else if (val is int) { return val; } else if (val is double) { return val.toInt(); } else { throw JRPCError("Not a number!"); } } double? double_fromJson(dynamic val) { if (val == null) { return null; } else if (val is int) { return val.toDouble(); } else if (val is double) { return val; } else { throw JRPCError("Not a number!"); } } bool? bool_fromJson(dynamic val) { if (val == null) { return null; } else if (val is bool) { return val; } else { throw JRPCError("Not a bool!"); } } String? String_fromJson(dynamic val) { if (val == null) { return null; } else if (val is String) { return val; } else { return val.toString(); // TODO: Either this or error // throw JRPCError("Not a string!"); } }