Package Exports
- jsonschema-nodewalker
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (jsonschema-nodewalker) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
Given the following schema:
const SCHEMA = {
type: 'object',
properties: {
title: {
type: 'string'
},
actors: {
type: 'array',
items: {
type: 'object',
properties: {
name: {
type: 'string'
},
gender: {
type: 'string'
}
}
}
}
}
};
$ npm install --save jsonschema-nodewalker
const walkNodes = require('jsonschema-nodewalker');
walkNodes(SCHEMA, (node, {name} = {}) => console.log('Hello from:', name));
That's it! You can do whatever you'd like in the onNode
callback, here we're
just logging the value out, but you could of course modify the node or anything
else.
The logger example above gives us an output of:
Hello from: undefined
Hello from: title
Hello from: actors
Hello from: undefined
Hello from: name
Hello from: gender