what is this string
:,
what format is this
your format needs to be corrected
JSON.parse cannot be because the JSON.parse conversion key value must be in double quotes, including specific query documents
what string substitution removal is possible, but access is also not accessible
use the replace () and splite () methods
to post the results you want. What array do you want?
do not use eval
use JSON.parse
there is something wrong with the part you posted, it should be in this format, [{name: "a"}, {name: "b"},.], which can generally be converted with JSON.parse ()
.
convert first to legal json format string, and then to js array
if you want to transfer this string, you can write
like this.
const str = '[{latitudes:123, longitude:, proname:5A }]'
const jsonStr = str.replace(
/"?((?:(?!\{).)+?)"?:"?((?:(?![\}|,|"]).)*)"?([,|\}])/g,
(_, b, c, d) => {
return `"${b.trim()}":"${c.trim()}"${d}`
},
)
const arr = JSON.parse(jsonStr)