4.1. JSON

In X-definitions, you can describe a model of JSON data to the xd:xon element. The name of the model is in the attribute name. The model is described as JSON text. The X-script for the values in place of the corresponding value. The X-script for maps and arrays is written in the directive %script. JSON data:
{ "cities" : [
    { "from": ["Brussels",
        {"to": "London", "distance": 322},
        {"to": "Paris", "distance": 265}
      ]
    },
    { "from": ["London",
        {"to": "Brussels", "distance": 322},
        {"to": "Paris", "distance": 344}
      ]
    }
  ]
}
The X-definition will be:
<xd:def xmlns:xd="http://www.xdef.org/xdef/4.2" name="Test" root="Distancies" >
  <xd:xon name="test">
    { "cities"  : [
        { %script = "occurs 1..*;",
          "from": [ "string();",
            { %script = "occurs 1..*;",
              "to": "jstring();",  "distance": "int();"
            }
    	  ]
        }
      ]
    }
  </xd:xon>
</xd:def>
You can try it HERE