- 🔄 Converts JSON ↔ YAML ↔ CSV ↔ XML
- 📂 Supports files with arrays of objects or arrays of arrays (csv-friendly)
- 🎨 Pretty prints JSON & YAML for readability
- 🧩 Uses
nokogirifor robust XML parsing & generation
- Ruby 3.x+ installed
nokogirigem (install withgem install nokogiri)
ruby converter.rb --from FORMAT --to FORMAT input_file output_fileFORMAT: json | yaml | csv | xml
input_file: your source file path
output_file: destination file path
ruby converter.rb --from json --to csv data.json data.csv
ruby converter.rb --from csv --to yaml data.csv data.yml
ruby converter.rb --from xml --to json data.xml data.jsonXML expects a root with multiple <item> children containing data fields
CSV with headers → array of hashes; without headers → array of arrays supported
If you see errors about .keys on Array, check your input file format — might be nested arrays instead of hashes
Script aims to handle common cases, but weird formats might cause trouble