JsonFieldGuard class
A powerful utility class for safe JSON parsing with detailed error reporting
This class provides methods to parse JSON values safely while offering crystal-clear error messages that help developers quickly identify and fix JSON parsing issues. Unlike standard parsing which gives cryptic errors, JsonFieldGuard tells you exactly which field failed and why.
Constructors
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
Static Methods
-
guard<
T> (String key, dynamic value, T parser(dynamic)) → T - Safely parse a JSON value and provide clear error if type mismatch occurs
-
guardList<
T> (String key, dynamic value, T itemParser(dynamic)) → List< T> - Parse a list with individual item validation
-
guardNotNull<
T> (String key, dynamic value, T parser(dynamic)) → T - Validate that a value is not null before parsing
-
guardWithContext<
T> (String key, dynamic value, T parser(dynamic), {String? fieldDescription, String? expectedFormat, List< String> ? commonValues}) → T - Parse a required field with enhanced error context