The popularity of JSON is ever-increasing, and XMLSpy is keeping pace. Over the past few product releases, we’ve added intelligent functionality for editing and converting JSON data to the product. Most recently, we’ve completed the circle with one-click conversion between XML Schemas and JSON Schemas, as well as sample instance generation and JSON Schema documentation generation.
Let’s walk through some common examples demonstrating this functionality – and see how these time-saving tools make XMLSpy the only JSON development tool you’ll need.
Convert XSD <-> JSON Schema
Developers are increasingly turning to JSON Schema to apply the benefits of data validation to JSON data exchanges. However, this requires significant time and effort to be allocated schema development – a bit of a contradiction compared to JSON’s promised simplicity.
Luckily, there’s no reason to re-invent the wheel. Given the large volumes of existing XML Schemas, the ability to convert from XSD to JSON Schema quickly and easily can allow developers to focus on implementation rather than building schemas from scratch, and XMLSpy supports this with one-click. It’s just as easy to convert from JSON Schema to XSD, for complete flexibility.
Let’s take a look at a fairly common transaction scenario – the purchase order. There are many existing XML Schemas for this use case, of course, including one that ships in the Examples directory of XMLSpy. Here’s the schema shown in the graphical XML Schema editor:
Using the Convert XML Schema to/from JSON Schema option in the Convert menu, I can specify conversion options…
…and click OK to generate the JSON Schema, shown here in the graphical JSON Schema editor:
And here’s a snippet of the corresponding JSON Schema code in Text View:
From here, you can edit the schema further in graphical or text view, or go on to generate a sample JSON instance.
This XML Schema/JSON Schema conversion functionality adds to existing support for converting between XML instance files and JSON instance files.
Generate Sample JSON Instances
Once you’ve got your JSON Schema, it’s useful to generate a sample instance based on it to give you a jumpstart on any additional editing.
The Generate Sample JSON File dialog in XMLSpy allows you to specify whether to generate non-mandatory object properties, the length of arrays, and repetitions of recursive definitions. You can also specify whether or not the active JSON Schema should be automatically assigned to the generated JSON sample file. Click OK, and you’ll immediately have a valid JSON instance to use as a starting point.
Here is a snippet of the sample generated from the JSON Schema above:
Generate JSON Schema Documentation
Documentation is an important part of schema development, allowing concise communication with other developers and providing clarity as a schema evolves. XMLSpy offers automatic JSON Schema documentation generation – a huge time saver – with numerous options that allow you to customize your documentation, and then output it in print and/or web formats.
Here’s a snippet of the documentation generated in HTML for the JSON Schema shown above:
Comprehensive JSON Development
The features described above round out JSON and JSON Schema functionality in XMLSpy, which now includes:
- Intelligent JSON editor with text and grid views
- Graphical JSON Schema editor
- Validation based on JSON Schema
- XML instance <-> JSON instance conversion (one or many files)
- XSD <-> JSON Schema conversion
- Sample JSON instance generation
- JSON Schema documentation
JSON Support Across the Product Line
If JSON data mapping and integration, such as generating JSON from or writing JSON to a relational database, is a requirement, you can find support in MapForce, Altova’s powerful any-to-any data mapping tool.