6.1. JSON

With X-definiton it is also possible to work with data formats as JSON, YAML etc. Let's have JSON data:
{ "date" : "2020-02-22",
  "cities" : [
    { "from": ["London",
        {"to": "Brussels", "distance": 322},
        {"to": "Paris", "distance": 344}
      ]
    }
  ]
}
The model of JSON data is described in the element xd:xon as a text value:
  <xd:def xmlns:xd="http://www.xdef.org/xdef/4.2" name="Example" root="test">
  <xd:xon name="test">
    { "date" : "date();",
      "cities"  : [
        {%script = "occurs 1..*;",
          "from": [
            "string();",
            {%script = "occurs 1..*;", "to": "jstring();", "distance": "int();"}
    	  ]
        }
      ]
    }
  </xd:xon>
</xd:def>
You can try it HERE