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: about 1 month ago
JSON representation
Highly configurable converter from JSON-schema to XML-schema (XSD).
- Host: GitHub
- URL: https://github.com/ethlo/jsons2xsd
- Owner: ethlo
- License: mit
- Created: 2013-06-25T04:23:03.000Z (almost 12 years ago)
- Default Branch: main
- Last Pushed: 2023-02-24T08:53:31.000Z (about 2 years ago)
- Last Synced: 2025-03-31T16:17:10.336Z (about 2 months ago)
- Topics: converter, java, json, json-schema, jsonschema, xml, xml-schema, xsd
- Language: Java
- Homepage:
- Size: 169 KB
- Stars: 83
- Watchers: 5
- Forks: 43
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
jsons2xsd
=========
[](https://search.maven.org/artifact/com.ethlo.jsons2xsd/jsons2xsd)
[](LICENSE)
[](https://coveralls.io/github/ethlo/jsons2xsd)
[](https://www.codacy.com/app/ethlo/jsons2xsd?utm_source=github.com&utm_medium=referral&utm_content=ethlo/jsons2xsd&utm_campaign=Badge_Grade)
[](https://travis-ci.org/ethlo/jsons2xsd)
[](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
```xmlcom.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();
```