anchor.diff:          specifiedType.root != BuiltList &&
           specifiedType.root != JsonObject) {
         if (specifiedType.isUnspecified) {
  -        return _toMapSpecifyType(object);
  +        return _toMapWithDiscriminator(object);
         } else {
  -        return _toMap(object, _alreadyHasStringKeys(specifiedType));
  +        return _toMap(object, _needsEncodedKeys(specifiedType));
         }
       } else {
         return object;
  
positive.code:       // Drop null values, they are represented by missing keys.
        if (value == null) return;
  
        result[i] = needToDecodeKeys ? _fromStringKey(key as String) : key;
        result[i + 1] = value;
        i += 2;
      });
      return result;
    }
  
    Object _fromStringKey(String key) {
      return JSON.decode(key);
    }
  }
  
negative.code:     return object;
    }
  
    /// Returns whether a type has keys that aren't supported by JSON maps; this
    /// only applies to `BuiltMap` with non-String keys.
    bool _needsEncodedKeys(FullType specifiedType) =>
        specifiedType.root == BuiltMap &&
        specifiedType.parameters[0].root != String;
  
    /// Converts serialization output, a `List`, to a `Map`, when the serialized
    /// type is known statically.
    Map _toMap(List list, bool needsEncodedKeys) {
      final result = {};
      for (int i = 0; i != list.length ~/ 2; ++i) {
        final key = list[i * 2];
        final value = list[i * 2 + 1];
        result[needsEncodedKeys ? _encodeKey(key) : key] = value;
      }
      return result;
    }
  
    /// Converts serialization output, a `List`, to a `Map`, when the serialized
    /// type is not known statically. The type will be specified in the
    /// [discriminator] field.
    Map _toMapWithDiscriminator(List list) {
      var type = list[0];
  
      // Length is at least two because we have one entry for type and one for
      // the value.
      if (list.length == 2) {
        // Just a type and a primitive value. Encode the value in the map.
        return <Object, Object>{discriminator: type, valueKey: list[1]};
      }
  
      if (type == 'list') {
        // Embed the list in the map.
        return <Object, Object>{discriminator: type, valueKey: list.sublist(1)};
      }
  