I'm having some issues with postgresql(9.4) and javascript. I'm trying to convert a jsonb[] datatype into an array/list of json values in javascript. For simplicity, my example contains only one element(json) in the array.
var s = { "player": "{\"{\\\\\"username\\\\\": \\\\\"JetJet13\\\\\", \\\\\"points\\\\\": 525, \\\\\"level\\\\\": 3"}\"}" };
Here's what I have tried so far.
JSON.parse(s.player); //this gives an error: SyntaxError: Unexpected token }
Here's what I'm looking for.
var s = { "player": [ {"username": "JetJet13", "points": 525, "level": 3} ] };
Any help will be appreciated.
player, rather an object within an object (which is illegal, as is evident by the error produced on parsing). How are you generating the JSON from Postgres?'{1, 2, 3, 4}'is what an array looks like in postgres. Check out this question stackoverflow.com/questions/20699196/…