
Converting JSON to YAML Without Losing Types or Quotes
Convert JSON to YAML with a YAML library so strings like yes, 3.10 and 02134 keep their quotes, and see what string formatting does to the same data.
Everything you need to level up your coding skills.

Convert JSON to YAML with a YAML library so strings like yes, 3.10 and 02134 keep their quotes, and see what string formatting does to the same data.

The three Java XML APIs on one 36.6 MB file: DOM ran out of memory at a 256 MB heap and took 1.03 s with 1 GB, while SAX and StAX ran in 32 MB in about 0.3 s.

Split a 36.6 MB XML file into eight valid files of 25,000 orders with iterparse in 1.5 seconds at 21 MB, and see why split -l produces broken XML.

Convert YAML to JSON with PyYAML and json, and handle the cases that break it: dates, sets, integer keys, NaN, anchors, several documents and complex keys.

Why cat breaks XML, and three ways that work: XInclude with xmllint, XSLT with document(), and lxml, with the xml:base attribute side effect of XInclude.

grep counts lines, not elements. Count XML elements correctly with xmllint, xmlstarlet and a streaming parser, and see why grep gave 20000 for 49819 lines.

Two different tools are called yq. Both read XML and print JSON or YAML, with different prefixes for attributes. See each one's output and which you have.

Change a value, add an attribute and delete an element in XML from a script with xmlstarlet or lxml, and compare with sed on diffs, comments and escaping.

Select values, make delimited lines, count nodes, list element paths and sort with xmlstarlet sel, and avoid the escaped ampersand in its default text output.

A working guide to converting JSON to CSV, XML, YAML, Excel, SQL and Markdown and back: what each format cannot hold, a 23 field round trip test, and checks.

Pretty-print one-line XML with xmllint, set the indent, strip blank text for stable diffs, get canonical form and change encoding, and see what it alters.

Read a Microsoft Project XML plan into tasks with durations, start dates, percent complete and predecessors, and learn how Visio files are zipped XML.
We send one email when a new article is published. No spam.