JSFiddle - React, Tailwind, and code Playground
HTML
<input type="text" id="project" value="" />
<input type="button" id="click" value="Store array" />
<input type="button" id="retrieve" value="Retrieve" />
JavaScript
var array = [
{id:1, product_id: 2, name: 'stack'},
{ id: 2, product_id: 2, name: 'overflow' }
];
$('#click').click(function() {
$('#project').val(JSON.stringify(array));
});
$('#retrieve').click(function() {
alert('Parsing ' + $('#project').val() + ".\n\nCheck your console");
console.log($.parseJSON($('#project').val()));
});