I have a like this object as a string. if that object like this below, no problem
var txt = '{ "title": "001188", "name": "Input 1", "data": "false" }'
var arr = [];
var obj = JSON.parse(txt);
arr.push(obj)
document.getElementById("demo").innerHTML = arr[0].name;
but if I try to convert this object, there was an error
var txt = '{ "title": "001188", "name": "Input 1", "data": "false" }, { "title": "001188", "name": "Input 2", "data": "false" }, { "title": "001188", "name": "Input 3", "data": "false" }, { "title": "001188", "name": "Input 4", "data": "false" }, { "title": "001188", "name": "Input 5", "data": "false" }'
var arr = [];
var obj = JSON.parse(txt);
arr.push(obj)
document.getElementById("demo").innerHTML = arr[0].name;
Error is below
Unexpected token , in JSON at position 57
How can I do this. Thanks
[and]at the beginning and end, so that you have an array of objects, which would be proper JSON again.