Jackson plugin
Overview
The Jackson plugin supports reading a (JSON, XML or CSV) file and converting the data to an object.
- Technologies addressed
- Dependency
-
io.qalipsis.plugin:qalipsis-plugin-jackson - Namespace in scenario
-
jackson() - Client library
-
JsonMapper: refer to FasterXML.
- Supported steps
-
-
csvToMap and csvToObject: reads a csv file, and converts the data to a Map (or an Object).
-
jsonToMap and jsonToObject: reads a json file and converts the data to a Map (or Object).
-
xmlToObject: reads an xml file and converts the data to an object.
-
csvToMap and csvToObject
The csvToMap and csvToObject steps within the Jackson plugin read a CSV resource (file, classpath resource, URL) and returns each item as an instance of an Object or Map.
- Ancestor
-
Step
- Functionality
-
The
csvToMapandcsvToObjectstep specification has atargetClassproperty to which the output lines should be mapped. The step reads a CSV file, converts the data to amap(or anobject) and pushes themap(orobject) to the next step. - Example
-
jackson().csvToMap { classpath(file) header { escapeChar('E') quoteChar('"') columnSeparator(';') withHeader() allowComments() column("1st value").double() column("2th value").string().array(",") column("3rd value").string(true) column("4th value").string(true) } } .jackson() .csvToObject(BatteryState::class) { classpath("battery-levels.csv") header { column("deviceId") column("timestamp") column("batteryLevel").integer() } unicast() } - Notable parameters
-
-
classpath(file): reads the data from a specified class path resource;fileis the path to the resource with the leading slash ignored. -
file(path): reads the data from a specified plain file in the file system;pathis the path to the file, either absolute or relative to the current working directory. -
url(url): specifies and links to theurlof the data resource. -
mapper: configures the JSON Mapper to deserialize the records.
-
- Tip
-
Only one path (
classpath(file),file(path), orurl(url)) to the resource is allowed for eachcsvToObjectorcsvToMapstep. - Reference documentation
-
Refer to the jackson documentation for further configuration and parameter information.
xmlToObject
The xmlToObject step within the Jackson plugin reads an XML resource (classpath, file, or url) and returns each item as an instance of an object of the specified class.
- Ancestor
-
Step
- Functionality
-
The
xmlToObjectstep specification has atargetClassproperty to which the output lines should be mapped. The step reads an XML file, converts the data to anObject, and pushes theObjectto the next step. - Example
-
jackson().xmlToObject(PojoForTest::class) { classpath(file) } - Notable parameters
-
-
classpath(file): reads the data from a specified class path resource;fileis the path to the resource with the leading slash ignored. -
file(path): reads the data from a specified plain file in the file system;pathis the path to the file, either absolute or relative to the current working directory. -
url(url): specifies and links to theurlof the data resource.
-
- Tip
-
Only one path (
classpath(file),file(path), orurl(url)) to the resource is allowed for eachxmlToObjectstep. - Reference documentation
-
Refer to the jackson documentation for further configuration and parameter information.
jsonToMap and jsonToObject
The jsonToMap and jsonToObject steps within the Jackson plugin read a JSON resource (file, classpath resource, URL) and returns each item as an instance of map or object).
- Ancestor
-
Step
- Functionality
-
The
jsonToMapandjsonToObjectstep specification has atargetClassproperty to which the output lines should be mapped. The step reads a JSON file, converts the data to aMap(or anObject) and pushes theMap(orObject) to the next step. - Example
-
jackson().jsonToMap() { classpath(file) } jackson().jsonToObject(PojoForTest::class) { classpath(file) } - Notable parameters
-
-
classpath(file): reads the data from a specifiedpathresource;fileis the path to the resource with the leading slash ignored. -
file(path): reads the data from a specified plain file in the file system;pathis the path to the file, either absolute or relative to the current working directory. -
url(url): specifies and links to theurlof the data resource.
-
- Tip
-
Only one path (
classpath(file),file(path), orurl(url)) to the resource is allowed for eachjsnToObjectorjsnToMapstep. - Reference documentation
-
Refer to the jackson documentation for further configuration and parameter information.