isJson static method
Validate that the specified value ist either a num, String, bool, Map or List. If the first check fails isJson checks if the value has a toJson() function - if so, the value is also valid
value
the value to validate, not null
Throws ArgumentError if the value falls out of the boundaries
Implementation
static void isJson(final dynamic value,
[String message = DEFAULT_JSON_MESSAGE]) {
GValidate.notNull(value, message);
if (!((value is num) ||
(value is String) ||
(value is bool) ||
(value is List) ||
(value is Map))) {
try {
value.toJson();
} on NoSuchMethodError {
throw new ArgumentError(message);
}
}
}