A console application designed to transform data files between JSON, XML, and CSV formats.
- Seamless conversion between JSON, XML, and CSV formats
- Straightforward command-line interface
- Clear and informative error reporting
- Handles tabular data structures
- Java version 21+
- Maven 3.6 or above
Execute the following command:
./mvnw clean packageThis process generates an executable JAR file located at target/file-converter.jar.
Run the application using:
java -jar target/file-converter.jar --input <source-file> --output <destination-file>| Parameter | Purpose | Mandatory |
|---|---|---|
--input |
Source file path | Yes |
--output |
Destination file path | Yes |
--help |
Display usage information | No |
The examples/ directory contains demonstration files:
examples/username.csv- Data in CSV formatexamples/username.json- Data in JSON formatexamples/username.xml- Data in XML format
Transform CSV to JSON:
java -jar target/file-converter.jar --input examples/username.csv --output result.jsonAccepts and produces arrays of simple objects:
[
{"id": "789", "name": "Robert", "email": "robert@company.org"},
{"id": "456", "name": "Jennifer", "email": "jennifer@company.org"}
]Individual objects are also valid:
{"id": "789", "name": "Robert", "email": "robert@company.org"}<?xml version="1.0" encoding="UTF-8"?>
<records>
<record>
<id>789</id>
<name>Robert</name>
<email>robert@company.org</email>
</record>
<record>
<id>456</id>
<name>Jennifer</name>
<email>jennifer@company.org</email>
</record>
</records>id,name,email
789,Robert,robert@company.org
456,Jennifer,jennifer@company.org- Text-based values: All data elements are handled as text strings during format conversion.
- Tabular data only: Complex nested objects and arrays are not processed. The tool will indicate an error when such structures are encountered.
| Condition | Response Message |
|---|---|
| File unavailable | Error: Input file 'path' could not be located |
| Malformed XML | Error: XML parsing failed: message |
| Unsupported extension | Error: File format '.xyz' is not supported |
| Malformed JSON | Error: JSON syntax error detected at line X |
| Complex data structure | Error: Complex nested structures cannot be processed. Use flat data |
| Missing input parameter | Error: Required --input argument not provided |
| Missing output parameter | Error: Required --output argument not provided |
Run the test suite with:
./mvnw test