4.1. JSON

In X-definition, you can describe the JSON data model in the "xd:json" element. The name of the model is in the "name" attribute. The model is described as text in JSON format. The X-script for the data values is written in place of the corresponding data value. The X-script for maps and arrays is written as the value of "%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:json name="test">
    { "cities"  : [
        { %script = "occurs 1..*;",
          "from": [ "string();",
            { %script = "occurs 1..*;",
              "to": "jstring();",  "distance": "int();"
            }
    	  ]
        }
      ]
    }
  </xd:json>
</xd:def>
You can try it HERE