Registry / serialization / jsonix-schema-compiler

jsonix-schema-compiler

JSON →
library2.3.9jsnpmunverified

Jsonix Schema Compiler is a Java-based tool that generates Jsonix mappings and JSON Schema definitions from XML Schema (XSD) files. Version 2.3.9 is the latest stable release, with active but infrequent updates. It is a companion to the Jsonix library for XML-JSON conversion. Key differentiators: handles complex XML Schema features like enums, minOccurs/maxOccurs, xs:duration, and built-in type detection. Requires Java runtime to run, integrates via Java JAR or Maven plugin. Unlike pure JavaScript alternatives, it provides full XSD compliance. Does not support XML Schema 1.1 and has no TypeScript type generation.

npm install jsonix-schema-compiler
INSTALL
IMPORT
SIG · JSONIX-SCHEMA-COMP
J
jsonix-schema-compiler
serializationjavascriptv2.3.9
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

Default
import { Default } from 'jsonix'
const Default = require('jsonix')
Jsonix itself is ESM-compatible; this is for consuming generated mappings.
Marshaller
import { Marshaller } from 'jsonix'
const Marshaller = require('jsonix').Marshaller
Named export from jsonix.
Unmarshaller
import { Unmarshaller } from 'jsonix'
const Unmarshaller = require('jsonix').Unmarshaller
Named export from jsonix.
compile
// not a JS import; use CLI: java -jar jsonix-schema-compiler-full.jar
import { compile } from 'jsonix-schema-compiler'
This package provides a JAR, not a JS module. Do not attempt to import JavaScript symbols from it.

Shows how to use the compiler via npm prepublish and then use generated mappings with Jsonix for XML marshalling/unmarshalling.

// First, install jsonix-schema-compiler and jsonix // npm install jsonix-schema-compiler jsonix // Then in package.json scripts: { "scripts": { "prepublish": "java -jar node_modules/jsonix-schema-compiler/lib/jsonix-schema-compiler-full.jar schema.xsd" } } // Run npm run prepublish to generate mapping file jsonschema.js // Then in your code: import { Default, Marshaller, Unmarshaller } from 'jsonix'; import { MyMapping } from './mapping/MyMapping.js'; const context = new Default([ MyMapping ]); const marshaller = new Marshaller(context); const unmarshaller = new Unmarshaller(context); // Example: marshal an object to XML const obj = { name: 'John', age: 30 }; const xml = marshaller.marshalString(obj); console.log(xml); // Example: unmarshal XML string const result = unmarshaller.unmarshalString(xml); console.log(result);
Debug
Known issues
gotchaThis package is a Java JAR, not a JavaScript module. Installing via npm does not provide a JavaScript API; you must invoke the JAR via command line or Java API.
fix
Use the CLI command `java -jar node_modules/jsonix-schema-compiler/lib/jsonix-schema-compiler-full.jar`. Do not expect to import anything from this package in JavaScript.
affects: all
deprecatedUsage of npm `prepublish` script is considered an antipattern. Since npm v5, `prepublish` runs on both `npm install` and `npm publish`, causing unintended generation. Use `prepare` instead.
fix
Change scripts from `prepublish` to `prepare` in package.json.
affects: >=2.3.2
gotchaJava Runtime Environment (JRE) is required to run the compiler. Node.js only, without Java, will fail.
fix
Ensure Java 8+ is installed and available in PATH.
affects: all
breakingVersion 2.3.7 introduced `required`, `minOccurs`, and `maxOccurs` in generated mappings. Mappings generated with older versions may produce different output when used with a newer Jsonix runtime.
fix
Regenerate mappings after upgrading to 2.3.7+ and use compatible Jsonix version.
affects: >=2.3.7
gotchaThe compiler JAR filename has changed across versions. Some versions use `jsonix-schema-compiler-full.jar`, others may have different names.
fix
Check the actual JAR file in `node_modules/jsonix-schema-compiler/lib/` after install and adjust command accordingly.
affects: all
Errors
Common errors & fixes
Error: Unable to access jarfile node_modules/jsonix-schema-compiler/lib/jsonix-schema-compiler-full.jar
JAR file not found or path incorrect.
fix
Verify that jsonix-schema-compiler is installed and the JAR exists. Check exact filename in lib/ directory.
Error: Could not find or load main class org.jvnet.jaxb2_commons.xjc.XJCTask
Running an older version of the JAR or incorrect invocation without main class.
fix
Use the correct JAR file: `jsonix-schema-compiler-full.jar` which is an executable JAR. Do not invoke without -jar.
ReferenceError: MyMapping is not defined
Generated mapping file is not imported or path is wrong.
fix
Ensure the generated mapping file path matches the import statement. The compiler outputs to a 'mapping' directory by default.
Upgrade
Version history
2.3.9latest on npm
Audit
Dependencies
jsonixrequiredRuntime dependency for consuming generated mappings
javarequiredRequired to execute the compiler JAR
Agent activity
3 hits · last 30 days
node
2
Meta
1
Resources
jsonix-schema-compiler — npm install jsonix-schema-compiler · libregistry