I have a string
that looks like this:
{"name":"Bob","age":20}###{"name":"Brian","age":12}###{"name":"Ryan","age":19}
As you can see, they JSON-like strings are demarcated by ###
My JS Code looks like this:
var data = <above string passed in from a function>
var data_list = data.split('###'); //should return an array with 3 JSON strings
Now I am trying to parse them individually like this:
console.log(JSON.parse(data_list[0])) // returns [object Object]
console.log(JSON.parse(data_list[1])) // returns [object Object]
BUT, the last one:
console.log(JSON.parse(data_list[2])) // Fails
Error:
Invalid JSON: <json>:28:1 Expected eof but found
}
^ in <eval> at line number 28
ALSO:
I printed out the contents of each index
from the data_list
array and they are valid JSON as per jsonlint.com