Class NullKeyTolerantMap

All Implemented Interfaces:
com.fasterxml.jackson.databind.JsonSerializable, Serializable, Cloneable, Map<String,Object>, SequencedMap<String,Object>

public class NullKeyTolerantMap extends LinkedHashMap<String,Object> implements com.fasterxml.jackson.databind.JsonSerializable
A Map that renders identically to a plain LinkedHashMap everywhere except through Jackson.

org.apache.solr.core.PluginInfo#writeMap groups a plugin's unnamed children (e.g. anonymous <processor> entries under an updateRequestProcessorChain) under a null key. Solr's legacy (v1) JSON response writer tolerates that null key natively, rendering it as "". Jackson, however, rejects null Map keys outright and (by default) omits null-valued entries entirely.

Wrap a config/plugin-derived map in this class to let the v2/JAX-RS (Jackson) response path render a self-describing key in place of the null key and keep null values, without changing what any non-Jackson consumer (e.g. a v1 handler reading the same map instance) sees.

See Also:
  • Constructor Details

    • NullKeyTolerantMap

      public NullKeyTolerantMap(String nullKeyReplacement)
      Parameters:
      nullKeyReplacement - the JSON field name to substitute for a null Map key, wherever one is found (at any nesting depth of Maps/Lists reachable from this instance).
  • Method Details

    • serialize

      public void serialize(com.fasterxml.jackson.core.JsonGenerator gen, com.fasterxml.jackson.databind.SerializerProvider serializers) throws IOException
      Specified by:
      serialize in interface com.fasterxml.jackson.databind.JsonSerializable
      Throws:
      IOException
    • serializeWithType

      public void serializeWithType(com.fasterxml.jackson.core.JsonGenerator gen, com.fasterxml.jackson.databind.SerializerProvider serializers, com.fasterxml.jackson.databind.jsontype.TypeSerializer typeSer) throws IOException
      Specified by:
      serializeWithType in interface com.fasterxml.jackson.databind.JsonSerializable
      Throws:
      IOException