Whether my database this XML file:

<?xml version="1.0" encoding="UTF-8"?>
<mots>
  <mot>
    <nom>iatrogène</nom>
    <racine>gène</racine>
  </mot>
  <mot>
    <nom>hippiatre</nom>
    <racine>hippo</racine>
  </mot>
</mots>

The only easy way to have JSON serialization with BaseX is to use the
"format=jsonml" option which returns:
["mots",
  ["mot",
    ["nom",
      "iatrogène"],
    ["racine",
      "gène"]],
  ["mot",
    ["nom",
      "hippiatre"],
    ["racine",
      "hippo"]]]

This output is not at all what I need, and  think I'm not the only one
in this case.
A quick search on Google give us simple online tools which have an
useful output:

http://codebeautify.org/xmltojson
{
    "mots": {
        "mot": [
            {
                "nom": "iatrogène",
                "racine": "gène"
            },
            {
                "nom": "hippiatre",
                "racine": "hippo"
            }
        ]
    }
}

http://www.utilities-online.info/xmltojson
{
  "mots": {
    "mot": [
      {
        "nom": "iatrogène",
        "racine": "gène"
      },
      {
        "nom": "hippiatre",
        "racine": "hippo"
      }
    ]
  }
}

Could we have this "easyjson" option in BaseX ? I know that it has not
at all the power of lossless conversion from JSON to XML and back,
like the "direct" and "attributes" options, but who really cares ?

I really think it's what most users need today to use BaseX with
client side JSON oriented frameworks.

Best regards

Florent

-- 
FLOSS Engineer & Lawyer

Reply via email to