
Product
Introducing Reports: An Extensible Reporting Framework for Socket Data
Explore exportable charts for vulnerabilities, dependencies, and usage with Reports, Socket’s new extensible reporting framework.
simplejsonform
Advanced tools
<form>.EasyJsonForm is a javascript form creation library for the cases when end-users need to create forms, such as survey or homework submission systems. With EasyJsonForm, users can easily create forms. Forms and form data are represented as objects that can be exported as JSON, retrieved and rebuilt whenever you can.
<select>. "Text" fields can be rendered as <input> or <textarea> according to what is set in its properties.Download the library and unzip its contents into a folder in your project. This folder will be referred as PATH througout the examples.
Add easyjsonform.js to your Javascript/HTML code.
<script src="PATH/easyjsonform.js"></script>
<script>
// your code here...
</script>
... or if you are using ES6 modules, use easyjsonform-module.js instead
import EasyJsonForm from './PATH/easyjsonform-module.js';
// your code here...
Both files are identical, execpt that the module file exports the EasyJsonForm class in a ES6/Javascript fashion.
var ejf = new EasyJsonForm('my-form');
The EasyJsonFormconstructor takes four parameters, but just the first is mandatory. It is the id of the form, which can be any string that uniquely identifies your form. When the form is rendered to the user the id of the enclosing div or form will have this value.
builderGet() method.<div id="my-container"></div>
...
<script src="PATH/easyjsonform.js"></script>
<script>
// Initializing form on the page
var ejf = new EasyJsonForm('my-form');
var myContainer = document.getElementById('my-container');
myContainer.appendChild(ejf.builderGet());
</script>
structureExport() method.<div id="my-container"></div>
<button onclick="saveForm()">Save Form</button>
...
<script src="PATH/easyjsonform.js"></script>
<script>
// Initializing form on the page
var ejf = new EasyJsonForm('my-form');
document.getElementById('my-container').appendChild(ejf.builderGet());
// Save method when user click on "Save form" button
function saveForm() {
// structure is a javascript object. It can be used to recreate the form
// using a EasyJsonForm object or can be saved in your database. For that,
// the object needs to be converted as a json string using JSON.stringify
let structure = ejf.structureExport();
let jsonStructure = JSON.stringify(structure);
// Replace console.log by your API call to save jsonStructure into your db
console.log(jsonStructure);
// If you want to update an input field (usually a hidden field) with the
// JSON representation of this form, you must provide a callback function.
// This is explained when we present the options (4th) argument.
}
</script>
<div id="my-container"></div>
...
<script src="PATH/easyjsonform.js"></script>
<script>
// Loading the structure. In real life, the structure would be retrieved from
// the database. In this example, we are just passing a hardcoded structure.
let jsonStructure = `[
{
"type": "text",
"label": "New Text 1",
"customattribute": "",
"mandatory": false,
"properties": {
"lengthmeasurement": "no",
"lengthmax": 0,
"lengthmin": 0,
"multiline": false
},
"value": ""
}
]`;
// The JSON needs to be converted to an object before it is passed to EasyJsonForm
let structure = JSON.parse(jsonStructure);
// Creating the EasyJsonForm, now with the structure of the saved form
var ejf = new EasyJsonForm('my-form', structure);
// Initializing the form builder on the page
document.getElementById('my-container').appendChild(ejf.builderGet());
</script>
You don't need to pass a structure as argument, you can simply not use the second argument at all. But if you need to pass the third or fourth arguments (see below), you will need to or pass null or an empty array [] as the second argument of the EasyJsonForm constructor.
formGet() (instead of builderGet()). The rest remain pretty much the same as the previous item. But, for this, a previously created structure is necessary.<div id="my-container"></div>
...
<script src="PATH/easyjsonform.js"></script>
<script>
// Loading the structure. In real life, the structure would be retrieved from
// the database. In this example, we are just passing a hardcoded structure.
let jsonStructure = `[
{
"type": "text",
"label": "New Text 1",
"customattribute": "",
"mandatory": false,
"properties": {
"lengthmeasurement": "no",
"lengthmax": 0,
"lengthmin": 0,
"multiline": false
},
"value": ""
}
]`;
// The JSON needs to be converted to an object, before it is passed to EasyJsonForm
let structure = JSON.parse(jsonStructure);
// Creating the EasyJsonForm, now with the structure of the saved form
var ejf = new EasyJsonForm('my-form', structure);
// Initializing the form the page
document.getElementById('my-container').appendChild(ejf.formGet());
</script>
easyjsonform-bootstrap.js or easyjsonform-bootstrap-module.js (if you are using ES6-modules).<div id="my-container"></div>
...
<script src="PATH/easyjsonform-bootstrap.js"></script>
<script src="PATH/easyjsonform.js"></script>
<script>
// Initializing form on the page with bootstrap styling
// The variable ejfBootstrapStyle is located at easyjsonform-bootstrap.js
var ejf = new EasyJsonForm('my-form', null, ejfBootstrapStyle);
document.getElementById('my-container').appendChild(ejf.builderGet());
</script>
Using ES6 modules:
<div id="my-container"></div>
...
<script type="module">
import EasyJsonForm from './PATH/easyjsonform-module.js';
import ejfBootstrapStyle from './PATH/easyjsonform-bootstrap-module.js';
// Initializing form on the page with bootstrap styling
var ejf = new EasyJsonForm('my-form', null, ejfBootstrapStyle);
document.getElementById('my-container').appendChild(ejf.builderGet());
</script>
outputStructureTable method now receives one parameter, the structure name $strname. No more parameters for classes names. If the client needs style modifications, it can do throgh the ids of elements. This function now outputs 4 HTML elements. 1: The toolbar, in a div with its own id (new), 2: the structure table with its id, 3: the HTML hidden input element with the value that can be used in a form, and 4: the javascript code all contained in one script tag.find_relative_path was removed, since there is no need to search for png files. There is no more http requests in the strcuture table.find_relative_path is static<pre>...</pre>, so the spacing is preserved.FAQs
this is package for formbuilder
The npm package simplejsonform receives a total of 1 weekly downloads. As such, simplejsonform popularity was classified as not popular.
We found that simplejsonform demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Product
Explore exportable charts for vulnerabilities, dependencies, and usage with Reports, Socket’s new extensible reporting framework.

Product
Socket for Jira lets teams turn alerts into Jira tickets with manual creation, automated ticketing rules, and two-way sync.

Company News
Socket won two 2026 Reppy Awards from RepVue, ranking in the top 5% of all sales orgs. AE Alexandra Lister shares what it's like to grow a sales career here.