All Projects → fnogatz → Xsd2json

fnogatz / Xsd2json

Licence: mit
Translate XML Schema into equivalent JSON Schema

Programming Languages

prolog
421 projects

Projects that are alternatives of or similar to Xsd2json

Understanding Json Schema
A website aiming to provide more accessible documentation for JSON schema.
Stars: ✭ 1,268 (+922.58%)
Mutual labels:  json-schema
Beerjson
Development repository for the BeerJSON format standard
Stars: ✭ 109 (-12.1%)
Mutual labels:  json-schema
Npoint
JSON storage bins with schema validation
Stars: ✭ 116 (-6.45%)
Mutual labels:  json-schema
Jesse
jesse (JSon Schema Erlang) is an implementation of a JSON Schema validator for Erlang.
Stars: ✭ 92 (-25.81%)
Mutual labels:  json-schema
Json Node Normalizer
'json-node-normalizer' - NodeJS module that normalize json data types from json schema specifications.
Stars: ✭ 105 (-15.32%)
Mutual labels:  json-schema
Go Jsonschema Generator
json-schemas generator based on Go types
Stars: ✭ 110 (-11.29%)
Mutual labels:  json-schema
Ajv
The fastest JSON schema Validator. Supports JSON Schema draft-04/06/07/2019-09/2020-12 and JSON Type Definition (RFC8927)
Stars: ✭ 10,340 (+8238.71%)
Mutual labels:  json-schema
Lurker
📖 The ultimate tool for documenting and testing APIs in Rails
Stars: ✭ 120 (-3.23%)
Mutual labels:  json-schema
React Jsonschema Form
A React component for building Web forms from JSON Schema.
Stars: ✭ 10,870 (+8666.13%)
Mutual labels:  json-schema
Hypothesis Jsonschema
Tools to generate test data from JSON schemata with Hypothesis
Stars: ✭ 112 (-9.68%)
Mutual labels:  json-schema
React Jsonschema Form Material Ui
📜 React - Material UI components for building Web forms from JSON Schema.
Stars: ✭ 95 (-23.39%)
Mutual labels:  json-schema
Laravel Json Schema
Create all your migrations and models from one JSON schema file.
Stars: ✭ 101 (-18.55%)
Mutual labels:  json-schema
Jsonschema
JSON Schema validation
Stars: ✭ 1,575 (+1170.16%)
Mutual labels:  json-schema
Graphql To Json Schema
GraphQL Schema to JSON Schema
Stars: ✭ 87 (-29.84%)
Mutual labels:  json-schema
Class Validator Jsonschema
Convert class-validator-decorated classes into JSON schema
Stars: ✭ 118 (-4.84%)
Mutual labels:  json-schema
Python Lambdarest
Flask like web framework for AWS Lambda
Stars: ✭ 84 (-32.26%)
Mutual labels:  json-schema
Schema Registry
Confluent Schema Registry for Kafka
Stars: ✭ 1,647 (+1228.23%)
Mutual labels:  json-schema
Liformbundle
Symfony Bundle to render Symfony Forms to JSON Schema
Stars: ✭ 124 (+0%)
Mutual labels:  json-schema
Typedload
Python library to load dynamically typed data into statically typed data structures
Stars: ✭ 120 (-3.23%)
Mutual labels:  json-schema
Liform
PHP library to render Symfony Forms to JSON Schema
Stars: ✭ 113 (-8.87%)
Mutual labels:  json-schema

xsd2json

Translate an XML Schema into equivalent JSON Schema based on SWI-Prolog and Constraint Handling Rules (CHR). For usage directly in Prolog or node.js.

Installation

First, make sure SWI-Prolog is installed. This module expects the swipl binary to be in PATH somewhere. In other words, type this:

swipl

If that works, so will xsd2json.

Using npm, you can install xsd2json by calling this:

npm install -g xsd2json

Or simply clone this repository and manually run the preinstall scripts to create pre-compiled Prolog files:

git clone https://github.com/fnogatz/xsd2json.git
npm run preinstall

Usage as CLI

If you install xsd2json via npm it will create a new command xsd2json:

xsd2json /path/to/your.xsd > /created/schema.json

Usage with node.js

The xsd2json module can be used programmatically as function or stream:

var xsd2json = require('xsd2json');
var filename = 'test.xsd';

// use as stream: Read from stdin
xsd2json(filename)
  .pipe(process.stdout);

// use as function
xsd2json(filename, function(err, schemaObject) {
  console.log(JSON.stringify(schemaObject, null, 2));
});

In addition to the command line options provided by the Prolog module, there are the following options available in the node.js module:

  • noExe: true | false (default): Use the native Prolog interface instead of the pre-compiled cli.exe. This might be useful for MacOS users (see issue #87 for more details).
  • swi: 'swipl' (default): Executable to call SWI-Prolog.

Usage with Prolog

xsd2json provides a predicate xsd2json(+XSD,-JSON), which holds for a given XML Schema (either file path, URL or stream). For instructions on how to use xsd2json programmatically in Prolog, have a look at the Prolog module's Readme.

Background

This tool has been developed as part of my Bachelor's Thesis at University of Ulm, Germany. The thesis (PDF) explains the general idea of the translation process via Prolog and Constraint Handling Rules (CHR). It also contains tabular and graphical representations of the implemented translations of XML Schema fragments. A shorter explanation of the translation process can be found in the CHR Workshop paper "From XML Schema to JSON Schema: Translation with CHR".

Project Structure

xsd2json is developed in a test-driven way. This reflects in the project's folder structure, too: The /lib-pl directory contains the Prolog and CHR stuff while you will find the TAP testing framework implemented in node.js under /test. Both directories contain their own Readme-File that explain their usage.

Known Bugs

xsd2json's tests are always executed using the latest stable release of SWI-Prolog. Make sure to have the latest version installed before you file a bug.

Apparently SWI-Prolog of version 7.2.x ships with a bug in the CHR implementation. Use version 7.4 or higher instead.

Alternatives

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].