FinchJson class
Provides utility methods for encoding and decoding JSON data.
The FinchJson class includes static methods for converting data to JSON format and
parsing JSON strings into Dart objects. It handles custom encoding for specific types
such as TString, ObjectId, DateTime, and Duration.
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
-
encodeMaps(
Map obj) → Map -
Convert Symbol maps to String maps
For example, {Symbol('name'): 'John'} becomes {'name': 'John'}
objis the map to be converted. Returns a new map with String keys. -
jsonDecoder(
String data) → dynamic - Parses a JSON-encoded string into a Dart object.
-
jsonEncoder(
Object data) → String - Converts an object to a JSON-encoded string.
-
symbolToKey(
Symbol symbol) → String -
Converts a Symbol to a string key.
The string key is derived from the symbol's name.
If the symbol represents a private member (starts with '_'), it is prefixed with '#'.
For example, Symbol('name') becomes 'name', and Symbol('_private') becomes '#_private'.
symbolis the symbol to be converted. Returns the string representation of the symbol. -
tryJson<
T, V> (dynamic data) → Map< T, V> ? -
Parses a JSON-encoded dynamic into a Dart object.
If parsing fails, returns null.
The
dataparameter can be any type of object to be parsed. Therqparameter is an optional Request object used for encoding TString instances. Returns a dynamic object representing the parsed JSON data, or null if -
tryJsonList(
dynamic data, {List def = const [], Request? rq}) → List? -
Parses a JSON-encoded dynamic into a List.
If parsing fails, returns the provided default list.
The
dataparameter can be any type of object to be parsed. Thedefparameter is the default list to return if parsing fails (default is an empty list). Therqparameter is an optional Request object used for encoding TString instances.