This section illustrates how to use XsdToJsonSchema and convert XSD to JSON schema.
After Setup the library will be installed by default under %ProgramFiles%\XsdToJsonSchema 1.1\
The set of DLL files are available at that location targeting .NET Framework 4.5 and above (folder XsdToJsonSchema 1.1\Bin\NET45\), .NET Standard 2.0 (folder XsdToJsonSchema 1.1\Bin\NetStandard20\) and .NET Standard 2.1 (folder XsdToJsonSchema 1.1\Bin\NetStandard21\)
In order to use the library, you have to reference the assembly file XsdToJsonSchema.dll from your .NET project and the assembly DLL must be deployed with your application.
Converting from XSD to JSON schema
The XSD to JSON conversion logic is available as a set of static methods in the XsdToJsonSchemaConverter class from the XsdToJsonSchema namespace.
This sample shows how to convert an XSD schema available as a String variable.
string xsd = File.ReadAllText("XMLFile1.xsd"); string jsonSchema = XsdToJsonSchema.XsdToJsonSchemaConverter.ConvertXsdToJsonSchema(xsd);
If the XSD is in a file and we want the conversion result to be also in a file we can use one of the overloaded methods for this purpose:
In case that the XSD schema is in some other kind of storage, for example, a database, then we can load the XSD schema contents into a System.IO.Stream and then convert it to a JSON schema into another Stream.