JsonConverter class

Converts arbitrary values from and to JSON (JavaScript Object Notation) strings.

Example

var value1 = JsonConverter.fromJson('{\'key\':123}'); // Result: { 'key': 123 }
var value2 = JsonConverter.toMap({ 'key': 123 }); // Result: '{ 'key': 123 }'

See TypeCode

Constructors

JsonConverter()

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

fromJson<T>(TypeCode? type, String value) → T?
Converts JSON string into a value of type specified by a TypeCode.
toJson(dynamic value) String?
Converts value into JSON string.
toMap(String value) Map<String, dynamic>
Converts JSON string into map object or returns empty map when conversion is not possible.
toMapWithDefault(String value, Map<String, dynamic> defaultValue) Map<String, dynamic>
Converts JSON string into map object or returns default value when conversion is not possible.
toNullableMap(String? value) Map<String, dynamic>?
Converts JSON string into map object or returns null when conversion is not possible.