xsd-json-converter (xjc)

'xsd-json-converter (xjc)' is a powerful Node library designed to convert ISO 20022 XSD files into JSON Schema. By transforming complex XSD structures into a more accessible JSON format, xjc simplifies programmatic data handling and enhances integration with other applications. This tool is ideal for developers looking to streamline workflows and make working with ISO 20022 data more efficient and flexible.

Features

  • Convert any given XSD to Json schema
  • Supports ISO 20022 XSD
  • Supports Windows, MacOS & Linux

How to consume

npm install -g xsd-json-converter
npm install xsd-json-converter

How to Use (CLI)

                        
                            xjc <source-path> <output-path>
                            
                            //Example
                            xjc xsd/pacs.008.001.10.xsd xsd/pacs.008.json 
                        
                    
How to Use (JavaScript)
                        
                            const xsd = require('xsd-json-converter').default;

                            xsd.convert('./pacs.008.001.10.xsd')
                                .then(output => console.log(output))
                                .catch(error => console.error(error));
                        
                    
How to Use (TypeScript)
                        
                            import xsd from "xsd-json-converter";

                            xsd.convert('./pacs.008.001.10.xsd')
                                .then(output => console.log(output))
                                .catch(error => console.error(error));
                        
                    
Generated Schema
                        
                            export interface XsdSchema
                            {
                              namespace:string;
                              schemaElement:SchemaElement
                            }
                            
                            export interface SchemaElement {
                                id: string;
                                name: string;
                                dataType: string | null;
                                minOccurs: string | null;
                                maxOccurs: string | null;
                                minLength: string | null;
                                maxLength: string| null;
                                pattern: string | null;
                                fractionDigits: string | null;
                                totalDigits: string | null;
                                minInclusive: string | null;
                                maxInclusive: string | null;
                                values: string[] | null;
                                isCurrency: boolean | null;
                                xpath: string | null;
                                elements: Schema[];
                            }
                        
                    
Generated Schema Example
                        
                            {
                                "namespace": "urn:iso:std:iso:20022:tech:xsd:pacs.008.001.10",
                                "schemaElement": {
                                    "id": "Document",
                                    "name": "Document",
                                    "dataType": null,
                                    "minOccurs": "1",
                                    "maxOccurs": null,
                                    "minLength": null,
                                    "maxLength": null,
                                    "pattern": null,
                                    "fractionDigits": null,
                                    "totalDigits": null,
                                    "minInclusive": null,
                                    "maxInclusive": null,
                                    "values": null,
                                    "isCurrency": false,
                                    "xpath": "Document",
                                    "elements":[
                                      ...
                                    ]
                                }
                            }