Class JsonFilterCommand
java.lang.Object
com.streamconverter.command.AbstractStreamCommand
com.streamconverter.command.impl.json.JsonFilterCommand
- All Implemented Interfaces:
IStreamCommand
JSON Filter Command Class
This class implements pure data extraction from JSON using TreePath expressions. Unlike JsonNavigateCommand which applies transformations, JsonFilterCommand only extracts/filters data based on specified paths without any modifications.
Features: - Extract specific elements using TreePath expressions - Preserve exact data types and structure of extracted elements - Streaming processing via Jackson Streaming API (JsonParser/JsonGenerator); the document is never fully loaded into memory - Support for simple path expressions including wildcards ($[*].field, $.array[*].nested.field)
-
Field Summary
Fields inherited from class com.streamconverter.command.AbstractStreamCommand
log -
Method Summary
Modifier and TypeMethodDescriptionstatic JsonFilterCommandFactory method for JSON filtering with typed path selector.voidexecute(InputStream inputStream, OutputStream outputStream) Executes the command on the provided input stream and writes the result to the output stream.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.streamconverter.command.IStreamCommand
commandName, withLogging, withLogging
-
Method Details
-
create
Factory method for JSON filtering with typed path selector.- Parameters:
jsonPath- the typed path to extract data- Returns:
- a JsonFilterCommand instance
- Throws:
IllegalArgumentException- if jsonPath is null
-
execute
Description copied from class:AbstractStreamCommandExecutes the command on the provided input stream and writes the result to the output stream.- Specified by:
executein interfaceIStreamCommand- Specified by:
executein classAbstractStreamCommand- 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.
-