anchor.diff:  
       var pairs = <String>[];
       for (var field in fields) {
  -      try {
  -        pairs.add('${_safeNameAccess(field)}: '
  -            '${_serialize(field.type, field.name, _nullable(field))}');
  -      } on UnsupportedTypeError {
  -        throw new InvalidGenerationSourceError(
  -            'Could not generate `toJson` code for `${friendlyNameForElement(field)}`.',
  -            todo: 'Make sure all of the types are serializable.');
  -      }
  +      pairs.add('${_safeNameAccess(field)}: ${_serializeField(field )}');
       }
       buffer.writeAll(pairs, ',\n');
   
  
positive.code:     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';
          }
  
          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('''
  void $toJsonMapHelperName(String key, dynamic value) {
    if (value != null) {
      $toJsonMapVarName[key] = value;
    }
  }''');
              directWrite = false;
            }
            buffer.writeln('$toJsonMapHelperName($safeJsonKeyString, '
                '${_serialize(field.type, fieldName, _nullable(field))});');
          }
        } on UnsupportedTypeError {
          throw new InvalidGenerationSourceError(
              'Could not generate `toJson` code for `${friendlyNameForElement(
                  field)}`.',
              todo: 'Make sure all of the types are serializable.');
        }
      }
  
  
negative.code:     return buffer.toString();
    }
  
    void _writeToJsonWithNullChecks(StringBuffer buffer,
        Iterable<FieldElement> fields, bool classIncludeIfNull) {
      buffer.writeln('{');
  
      buffer.writeln('var $toJsonMapVarName = <String, dynamic>{');
  