Class JsonNavigateCommand

java.lang.Object
com.streamconverter.command.AbstractStreamCommand
com.streamconverter.command.impl.json.JsonNavigateCommand
All Implemented Interfaces:
IStreamCommand

JSON Navigation Command for applying transformations to JSON data

This command navigates through JSON structures and applies transformations using rules while preserving the overall JSON structure. It focuses purely on navigation and transformation, not extraction.

Responsibilities: - Navigate to specified JSON paths - Apply transformation rules to matching elements - Preserve JSON structure during transformation - Stream processing for memory efficiency

  • Method Details

    • create

      public static JsonNavigateCommand create(TreePath treePath, IRule rule)
      Factory method for creating a JSON navigation command with TreePath and rule.
      Parameters:
      treePath - the TreePath to select data
      rule - the transformation rule to apply to selected elements
      Returns:
      a JsonNavigateCommand that transforms the specified path with the given rule
      Throws:
      IllegalArgumentException - if treePath or rule is null
    • execute

      public void execute(InputStream inputStream, OutputStream outputStream) throws IOException
      Description copied from class: AbstractStreamCommand
      Executes the command on the provided input stream and writes the result to the output stream.
      Specified by:
      execute in interface IStreamCommand
      Specified by:
      execute in class AbstractStreamCommand
      Parameters:
      inputStream - The input stream to read data from.
      outputStream - The output stream to write data to.
      Throws:
      IOException - If an I/O error occurs during the execution of the command.