Class FlatteningXContentParser

All Implemented Interfaces:
Closeable, AutoCloseable, XContentParser

public class FlatteningXContentParser extends XContentSubParser
A subclass of XContentSubParser that provides the functionality to flatten the field names by prefixing them with the provided parent name.
  • Constructor Details

    • FlatteningXContentParser

      public FlatteningXContentParser(XContentParser parser, String parentName)
      Constructs a FlatteningXContentParser with the given parent name and wraps an existing XContentParser.
      Parameters:
      parser - The XContentParser to be wrapped and extended with flattening functionality.
      parentName - The parent name to be used as a prefix for immediate children.
  • Method Details

    • currentName

      public String currentName() throws IOException
      Retrieves the name of the current field being parsed. If the current parsing level is 1, the returned field name will be constructed by prepending the parent name to the delegate's currentFieldName, otherwise just delegate.
      Specified by:
      currentName in interface XContentParser
      Overrides:
      currentName in class FilterXContentParser
      Returns:
      The current field name, potentially modified by prepending the parent name as a prefix.
      Throws:
      IOException - If an I/O error occurs during parsing.