Output nested JSON or XML

<< Click to Display Table of Contents >>

Navigation:  How do I? >

Output nested JSON or XML

You can use the dot ('.') character in the column header to show nesting. For example:

unflatten-table

Is output to JSON as:

[

  {

    "name": "Avocado Dip",

    "carb": "2",

    "cholesterol": "5",

    "fiber": "0",

    "minerals": {

      "ca": "0",

      "fe": "0"

    },

    "protein": "1",

    "sodium": "210",

    "vitamins": {

      "a": "0",

      "c": "0"

    }

  }

]

 

And to XML as:

<?xml version="1.0" encoding="UTF-8"?>

<root>

  <record>

    <name>Avocado Dip</name>

    <carb>2</carb>

    <cholesterol>5</cholesterol>

    <fiber>0</fiber>

    <protein>1</protein>

    <sodium>210</sodium>

    <minerals>

      <ca>0</ca>

      <fe>0</fe>

    </minerals>

    <vitamins>

      <a>0</a>

      <c>0</c>

    </vitamins>

  </record>

</root>

 

For more details see:

JSON format

XML format