xml2json
Quick Start
- Command:
cat record.xml | xml2json > record.json - Local executable:
/home/vimalinx/miniforge3/envs/bio/bin/xml2json - Full reference: references/help.md
When To Use This Tool
- Convert XML payloads into pretty-printed JSON for downstream scripting.
- Bridge XML-producing NCBI / EDirect commands into JSON-oriented tools.
- Inspect XML structure in a friendlier key/value form when the legacy converter dependency is available.
Common Patterns
# 1) Convert an XML document from stdin into JSON
cat record.xml | xml2json > record.json
# 2) Stream XML into JSON and inspect the first lines
cat record.xml | xml2json | sed -n '1,40p'
Recommended Workflow
- Confirm the XML input is the actual payload you want to convert, not a filename string or shell fragment.
- Pipe the XML into
xml2json; the script reads stdin wholesale. - Validate that the Perl dependencies load before trying a batch conversion.
- Inspect the first JSON objects before handing them to downstream code.
Guardrails
- This script is a Perl program that reads only from stdin and depends on
XML::SimpleplusJSON::PP. - In the current environment it cannot start because
XML::Simple.pmis missing, and--help/--versionfail with the same dependency error. - Because it uses
XML::Simple, the output structure can collapse repeated XML elements into arrays/hashes in ways that differ from hand-written JSON schemas. - Treat this as a legacy converter and validate its JSON shape on representative XML before building automation around it.