Converting JSON Schema To DOM Elements In Real-Time
Convert JSON Schema to DOM elements with schema2dom function. Supports array, object, integer, number, string, boolean and enum types. Example usage: `schema2dom({type:"object",properties:{n:{type:"number"},s:{type:"string"}}})
Using https://dev.to/yne/a-one-liner-for-createelement-with-attributes-and-children-55nh The following snippet convert any JSON Schema to DOM elements. const el = (tag, props = {}, ch = [], attrs = {}) => ch.reduce((e, c) => (e.appendChild(c), e), Object.entries(attrs).reduce((e, [k, v]) => (e.setAttribute(k, v), e), Object.assign(document.createElement(tag), Object.fromEntries(Object.entries(props).filter(([key, value]) => value !== undefined))))); function schema2dom(item, name = "", parent = {}) { let ul, total; // this total <input> track if we stay in minItems/maxItems if (item....