ISO20022 — XSD to JSON Schema [PART 5]


In this article we will discuss generating a ISO20022 JSON Schema from a XSD Schema.

There have been other tools that help with this task. However i wanted to test the waters by coding this myself.

This is the fifth article in a five part series

Part One

Part Two

Part Three

Part Four

Part Five — This Article


The code i have written is Kotlin code for JSON Schema Creation from XSD Schema and is available here .

XSD Schemas used

Two XSD Schemas have been taken from the website

You can see the files here: One is pacs.008.001.09.xsd and the other is camt.050.001.05

JSON Schemas Created

The Created JSON Schemas are visible here : One is pacs.008.001.09.schema.json and the other is camt.050.001.05.schema.json


There seems to be almost double the lines of code in the JSON Schemas as compared to the XSD Schemas

JSON has just the id and schema attributes. One of them “Schema” is used for the version of JSON schema, so only one id attribute out of the box for namespaces.

When converting from an XSD schema there could be loss of context as ISO20022 Schema does have many namespaces as a normal aspect of an XSD schema.

XSD has many names-spaces for example

<xs:schema xmlns="urn:iso:std:iso:20022:tech:xsd:pacs.008.001.09" xmlns:xs="" elementFormDefault="qualified" targetNamespace="urn:iso:std:iso:20022:tech:xsd:pacs.008.001.09">

JSON has only two attribute for namespaces

"$schema": "",
"id": "urn:iso:std:iso:20022:tech:xsd:pacs.008.001.09"

XSD can have unbounded types

<xs:element maxOccurs="unbounded" minOccurs="0" name="ChrgsInf" type="Charges7"/>

JSON cannot have unbounded types

"ChrgsInf": {
"minItems": 0,
"maxItems": 999,
"type": "array",
"items": {
"$ref": "#/definitions/Charges7"

Code to change unbounded to 999

when {value.equals(UNBOUNDED, ignoreCase = true) -> complexElement.maximum = 999
else -> complexElement.maximum = Integer.valueOf(value)}
  1. XSD has clear composition with simple and complex types with clear choices and sequences
  2. in JSON Schema, we could build similar structures though they look forced and may not build up quite as well

XSD — Composition with sequence and complex types

<xs:complexType name="Charges7">
<xs:element name="Amt" type="ActiveOrHistoricCurrencyAndAmount"/>
<xs:element name="Agt" type="BranchAndFinancialInstitutionIdentification6"/>

JSON — Supports composition with objects and references but no sequence

"Charges7": {
"type": "object",
"properties": {
"Amt": {
"$ref": "#/definitions/ActiveOrHistoricCurrencyAndAmount"
"Agt": {
"$ref": "#/definitions/BranchAndFinancialInstitutionIdentification6"


Please do have a look at the Gitlab code here. By all means feel free to contribute if you would like to do so. Leave me a comment here so i know.

XSD and JSON are built at different times and maybe for different purposes.

Fitting an ISO20022 Schema in to a JSON Schema may not convey the same aspects and in some cases we may even loose some information e.g. namespaces, unbounded elements and the like.

Careful considerations may be needed to make sure that the same business context is conveyed when moving from a XSD Schema to a JSON Schema.




Principal Architect at Mastercard

Love podcasts or audiobooks? Learn on the go with our new app.

Creating a React app for beginners

Javascript Basics — Var | Let | Const

Scraping Web Apps using Direct HTTP Request

Getting started with Yarn 2 and TypeScript

How to build a Multi-user Notebook Application with Vue3, Vuex and Firebase: Login, Signup, Forgot…

Fantasy themed programming flashcards

Interactive Arrays pt 1.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Suchak Jani

Suchak Jani

Principal Architect at Mastercard

More from Medium

How much memory does a Java server actually need? (Part 1/3)

Bug tracking: fixing hibernate heap problems

Offset Pagination for LDAP (Lightweight Directory Access Protocol) (Java)

import Json dependency in JAVA