dson library

Classes

Annotation
Class used to make annotations listed on ClassMirror
ClassMirror
reflects a Dart language class.
DeclarationMirror
reflects attributes declared in a Dart program.
FunctionMirror
reflects functions declared in a Dart program.
IgnoreIf
Annotation that tells parser to ignore the variable if the ignoreIfFunction returns true
Mirror
Base class for mirrors
Reflectable
Annotation needed to generate ClassMirror for every class
Serializable
annotation used to determine which files will be processed by the generator
SerializableMap
Interface that should be implemented by all the generated serializable classes
SerializedName
Annotation class to describe properties of a class member.

Constants

cyclical → const _Cyclical
this annotation describes if the objects contains cyclical reference to other objects
ignore → const _Ignore
Annotation that tells parser to ignore a variable or getter
reflectable → const Reflectable
Annotation needed to generate ClassMirror for every class
serializable → const Serializable
Shorthand annotation of Serializable used to determine which classes will be processed by the generator
uId → const _UId
sets which attribute will be used as unique identifier

Properties

classMirrors Map<Type, ClassMirror?>
returns the map of Type-ClassMirror
no setter
functionMirrors Map<Function, FunctionMirror>
returns the map of Function-FunctionMirror combination
no setter
getClassMirrorFromGenericInstance GetClassMirrorFromGenericInstance
getter/setter pair

Functions

fromJson(String jsonStr, dynamic type) → dynamic
Creates a new instance of type, parses the json in jsonStr and puts the data into the new instance.
fromMap(Object dataObject, dynamic type) → dynamic
Creates a new instance of type and maps the data of dataObject into it.
fromSerialized(dynamic serialized, dynamic factory) → dynamic
Converts the serialized value into its respective complex object value depending on the result of the factory function.
fromSerializedDateTime(dynamic serialized) → dynamic
Converts the serialized integer or ISO formatted String into a Datetime value
fromSerializedEnum(int? serialized, Type type, Function factory) → dynamic
Converts the serialized integer value into an enum in dependence of the factory result
initClassMirrors(Map<Type, ClassMirror> classMirrors) → void
adds to a map containing a Map with Type as keys and ClassMirrors as values
initFunctionMirrors(Map<Function, FunctionMirror> classMirrors) → void
adds to a map containing a Map<Function, FunctionMirror> as values
isPrimitive(dynamic value) bool
Checks if the value is primitive (String, number, boolean or null)
isPrimitiveType(Type type) bool
Checks if the type is either bool, String, int, num, double, or dynamic
isSimple(dynamic value) bool
Checks if the value is primitive, DateTime, List, or Map
isSimpleType(Type type) bool
Checks if the type is either primitive (see isPrimitiveType), List, Set, or Map;
objectToSerializable(dynamic object, {dynamic expand, dynamic exclude, String? fieldName}) → dynamic
Converts the object to a serializable Map, String, int, DateTime or any other serializable object.
reflect(dynamic instance) ClassMirror?
Returns the ClassMirror corresponding to the runtime type of the instance
reflectFunction(Function function) FunctionMirror?
Returns the FunctionMirror corresponding to the function
reflectType(Type type) ClassMirror?
Returns the ClassMirror corresponding to the type
throwFieldNotFoundException(Object? key, String type) → dynamic
toJson(dynamic object, {bool parseString = false, dynamic expand, dynamic exclude}) String
Serializes the object to a JSON string.
toMap(dynamic object, {dynamic expand, dynamic exclude, String fieldName = ''}) Map
Converts the non-primitive object to a serializable Map.

Typedefs

FunctionCall = dynamic Function([List? positionalParams, Map<String, dynamic>? namedParams])
GetClassMirrorFromGenericInstance = ClassMirror? Function(dynamic instance)
IgnoreIfFunction = bool Function({dynamic current_val, dynamic orig_val, dynamic user})
Function used to get if the variable should be ignored

Exceptions / Errors

EntityDescriptionMissing
This exception only appears in JavaScript if the ENTITY_MAP doesn't contain a description of a Class which dartson tries to parse.
FieldNotFoundException
IncorrectTypeTransform
This exception is thrown if the parser tries to convert a value of a different type.
NoConstructorError
This exception is thrown when a Class of mirr should be initiated but doesn't have a constructor without or only optional arguments.