Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/ethlo/jsons2xsd

Highly configurable converter from JSON-schema to XML-schema (XSD).
https://github.com/ethlo/jsons2xsd

converter java json json-schema jsonschema xml xml-schema xsd

Last synced: 1 day ago
JSON representation

Highly configurable converter from JSON-schema to XML-schema (XSD).

Awesome Lists containing this project

README

        

jsons2xsd
=========
[![Maven Central](https://img.shields.io/maven-central/v/com.ethlo.jsons2xsd/jsons2xsd.svg)](https://search.maven.org/artifact/com.ethlo.jsons2xsd/jsons2xsd)
[![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](LICENSE)
[![Coverage Status](https://coveralls.io/repos/github/ethlo/jsons2xsd/badge.svg)](https://coveralls.io/github/ethlo/jsons2xsd)
[![Codacy Badge](https://api.codacy.com/project/badge/Grade/b60e8e4fd0d541c5ac669c971850316f)](https://www.codacy.com/app/ethlo/jsons2xsd?utm_source=github.com&utm_medium=referral&utm_content=ethlo/jsons2xsd&utm_campaign=Badge_Grade)
[![Build Status](https://travis-ci.org/ethlo/jsons2xsd.svg)](https://travis-ci.org/ethlo/jsons2xsd)
[![GitHub issues open](https://img.shields.io/github/issues/ethlo/jsons2xsd.svg)](https://github.com/ethlo/jsons2xsd/issues)

[JSON-schema](http://json-schema.org/) to [XML schema](https://www.w3.org/TR/xmlschema11-1/) converter written in Java.

## Dependency
```xml

com.ethlo.jsons2xsd
jsons2xsd
2.3.0

```
## Snapshots

```xml


sonatype-nexus-snapshots

true

https://oss.sonatype.org/content/repositories/snapshots

```

## Usage

```java
try (final Reader r = ...)
{
final Config cfg = new Config.Builder()
.targetNamespace("http://example.com/myschema.xsd")
.name("array")
.build();
final Document doc = Jsons2Xsd.convert(r, cfg);
}
```

### Example input
```json
{
"type":"array",
"items":{
"type":"object",
"properties":{
"price":{
"type":"number",
"minimum":0
},
"name":{
"type":"string",
"minLength":5,
"maxLength":32
},
"isExpired":{
"default":false,
"type":"boolean"
},
"manufactured":{
"type":"string",
"format":"date-time"
}
},
"required":[
"price",
"name",
"manufactured"
]
}
}
```

### Example output
```xml





















```

## Support for non-standard types and formats

### Ignore unknown JSON formats
```java
final Config cfg = new Config.Builder()
.ignoreUnknownFormats(true)
...
.build();
```

### Register custom JSON formats
```java
final Config cfg = new Config.Builder()
.customTypeMapping(JsonSimpleType.INTEGER, "int64", XsdSimpleType.LONG)
.customTypeMapping(JsonSimpleType.INTEGER, "int32", XsdSimpleType.INT)
.customTypeMapping(JsonSimpleType.STRING, "ext-ref", XsdSimpleType.STRING)
...
.build();
```

### Register non-JSON types
```java
final Config cfg = new Config.Builder()
.nonJsonTypeMapping("date-time", XsdSimpleType.DATE_TIME)
.nonJsonTypeMapping("int", XsdSimpleType.INT)
...
.build();
```