store object in input value code example
Example: store object in input value
// encoding
let obj = {
key1: "foo",
key2: "bar"
};
document.querySelector('body').insertAdjacentHTML('beforeend', `<input name="sample_input" id="input" value=${encodeURIComponent(JSON.stringify(obj))}>`);
// decoding
JSON.parse(decodeURIComponent(document.querySelector('#input').value));