JsonUtils class

Utility class for JSON parsing and type conversion.

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

cleanJsonResponse(String? value) String?
Cleans a JSON response string by removing escaped quotes and outer quotes.
countIterableJson(dynamic json, {String separator = ','}) int
Counts items in an iterable or comma-separated string.
isJson(String? value, {bool testDecode = false, bool allowEmpty = false}) bool
Checks if a string appears to be valid JSON.
jsonDecodeSafe(String? jsonString) → dynamic
Safely decodes a JSON string, returning null on error.
jsonDecodeToMap(String? jsonString) Map<String, dynamic>?
Decodes a JSON string to a Map.
toBoolJson(dynamic json, {bool isCaseSensitive = true}) bool?
Converts JSON to a boolean.
toDateTimeEpochJson(dynamic json, JsonEpochScale scale) DateTime?
Converts an epoch timestamp to DateTime.
toDateTimeJson(dynamic json) DateTime?
Converts JSON to a DateTime.
toDoubleJson(dynamic json) double?
Converts JSON to a double.
toDoubleListJson(dynamic json) List<double>?
Converts JSON to a list of doubles.
toIntJson(dynamic json) int?
Converts JSON to an integer.
toIntListJson(dynamic json) List<int>?
Converts JSON to a list of integers.
toListDynamic(dynamic value) List?
Converts a value to a dynamic list if it is one.
toListMap(List? valueList) List<Map<String, dynamic>>?
Converts a dynamic list to a list of maps.
toStringJson(dynamic json, {bool trim = true, bool makeUppercase = false, bool makeLowercase = false, bool makeCapitalized = false}) String?
Converts JSON to a string with optional transformations.
toStringListJson(dynamic json, {String separator = ','}) List<String>?
Converts JSON to a list of strings.
tryJsonDecode(String? value, {bool cleanInput = false}) Map<String, dynamic>?
Attempts to decode a JSON string to a Map.
tryJsonDecodeList(String? value) List<String>?
Attempts to decode a JSON string to a list of strings.
tryJsonDecodeListMap(String? value) List<Map<String, dynamic>>?
Attempts to decode a JSON string to a list of maps.