anchor.diff:      var directWrite = true;
   
       for (var field in fields) {
  -      var fieldName = field.name;
  -      try {
  -        var safeJsonKeyString = _safeNameAccess(field);
  -
  -        // If `fieldName` collides with one of the local helpers, prefix
  -        // access with `this.`.
  -        if (fieldName == toJsonMapVarName || fieldName == toJsonMapHelperName) {
  -          fieldName = 'this.$fieldName';
  +      var safeFieldAccess = field.name;
  +      var safeJsonKeyString = _safeNameAccess(field);
  +
  +      // If `fieldName` collides with one of the local helpers, prefix
  +      // access with `this.`.
  +      if (safeFieldAccess == toJsonMapVarName ||
  +          safeFieldAccess == toJsonMapHelperName) {
  +        safeFieldAccess = 'this.$safeFieldAccess';
  +      }
  +
  +      if (_includeIfNull(field, classIncludeIfNull)) {
  +        if (directWrite) {
  +          buffer.writeln('$safeJsonKeyString : '
  +              '${_serializeField(field, accessOverride:  safeFieldAccess)},');
  +        } else {
  +          buffer.writeln('$toJsonMapVarName[$safeJsonKeyString] = '
  +              '${_serializeField(field, accessOverride:  safeFieldAccess)};');
           }
  -
  -        if (_includeIfNull(field, includeIfNull)) {
  -          if (directWrite) {
  -            buffer.writeln('$safeJsonKeyString : '
  -                '${_serialize(field.type, fieldName, _nullable(field))},');
  -          } else {
  -            buffer.writeln('$toJsonMapVarName[$safeJsonKeyString] = '
  -                '${_serialize(field.type, fieldName, _nullable(field))};');
  -          }
  -        } else {
  -          if (directWrite) {
  -            // close the still-open map literal
  -            buffer.writeln('};');
  -            buffer.writeln();
  -
  -            // write the helper to be used by all following null-excluding
  -            // fields
  -            buffer.writeln('''
  +      } else {
  +        if (directWrite) {
  +          // close the still-open map literal
  +          buffer.writeln('};');
  +          buffer.writeln();
  +
  +          // write the helper to be used by all following null-excluding
  +          // fields
  +          buffer.writeln('''
   void $toJsonMapHelperName(String key, dynamic value) {
     if (value != null) {
       $toJsonMapVarName[key] = value;
     }
   }''');
  -            directWrite = false;
  -          }
  -          buffer.writeln('$toJsonMapHelperName($safeJsonKeyString, '
  -              '${_serialize(field.type, fieldName, _nullable(field))});');
  +          directWrite = false;
           }
  -      } on UnsupportedTypeError {
  -        throw new InvalidGenerationSourceError(
  -            'Could not generate `toJson` code for `${friendlyNameForElement(
  -                field)}`.',
  -            todo: 'Make sure all of the types are serializable.');
  +        buffer.writeln('$toJsonMapHelperName($safeJsonKeyString, '
  +            '${_serializeField(field, accessOverride:  safeFieldAccess)});');
         }
       }
   
  
positive.code:   Iterable<TypeHelper> get _allHelpers =>
        [_typeHelpers, _coreHelpers].expand((e) => e);
  
    /// [expression] may be just the name of the field or it may an expression
    /// representing the serialization of a value.
    String _serialize(DartType targetType, String expression, bool nullable) =>
  
negative.code: 
      var pairs = <String>[];
      for (var field in fields) {
        pairs.add('${_safeNameAccess(field)}: ${_serializeField(field )}');
      }
      buffer.writeAll(pairs, ',\n');
  
  