I have this JavaScript string that contains and array of malformed JSON and I would like to parse it as the array it represents. The string goes:
variable = [{ var1: 'value11', var12: 'value2', var3: 'value13' }, { var1: 'value21', var2: 'value22', var3: 'value23' }]
Is it possible to parse this so that it becomes an actual array?
I’m assuming that
variable =is also returned as part of the string, so correct me if I’m wrong.If you’re using JavaScript, you can eval that, and then use it. Unfortunately this does mean that you’re stuck with that variable name though.
http://jsfiddle.net/2xTmh/