We should be more ambitious about ensuring consistency when serializing data back to its original representation, and how to achieve it. This is the status quo:
Format
Serialize Function
Parse Function
XML
fn:serialize($input)
fn:parse-xml
JSON
fn:serialize($input, map { 'method': 'json' })
fn:parse-json
JSON
fn:xml-to-json($input)
fn:json-to-xml
XHTML
fn:serialize($input, map { 'method': 'xhtml' })
fn:parse-html
HTML
fn:serialize($input, map { 'method': 'html' })
fn:parse-html
CSV
still missing
fn:parse-csv and variants
In BaseX, the XML created by fn:json-to-xml can already be serialized back to JSON as follows (related: #759):
We should be more ambitious about ensuring consistency when serializing data back to its original representation, and how to achieve it. This is the status quo:
fn:serialize($input)
fn:parse-xml
fn:serialize($input, map { 'method': 'json' })
fn:parse-json
fn:xml-to-json($input)
fn:json-to-xml
fn:serialize($input, map { 'method': 'xhtml' })
fn:parse-html
fn:serialize($input, map { 'method': 'html' })
fn:parse-html
fn:parse-csv
and variantsIn BaseX, the XML created by
fn:json-to-xml
can already be serialized back to JSON as follows (related: #759):For CSV, we’ve introduced a CSV serialization method that supports all CSV flavors we support (see CSV Module for more details):
Related (parse functions): #748