Simpan objek dalam nilai input
// 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));
somdev