fromJson method

void fromJson(
  1. Map<String, dynamic> jsonObj, {
  2. bool debug = false,
})

Apply/Clone from json object

  • Trigger save unless wrapped in noSave
  • Override this if using nested type/object

Implementation

void fromJson(Map<String, dynamic> jsonObj, {bool debug = false}) {
  try {
    // Deep copy to ensure [obj] won't be modified externally afterwards
    obj = jsonDecode(jsonEncode(jsonObj));
    if (debugLogJsonContent) {
      lazy.log('$runtimeType.fromJson():${jsonObj.toString()}',
          forced: debugLogJson || debug);
    } else {
      lazy.log('$runtimeType.fromJson():${jsonObj.toString().length}',
          forced: debugLogJson || debug);
    }
    save(debugMsg: '$runtimeType.fromJson()');
  } catch (e) {
    lazy.log('$runtimeType.fromJson():catch():$e');
  }
}