Parse JSON string into an array

javascript, json

Solution

Something like this. Is that trailing comma intentional?

var getDayArray = JSON.parse(data).day0.split(",")

Problem

I'm trying to parse a string from JSON and turn those elements into an array in Javascript. Here's the code. ``` var data = "{"fname":"Todd","lname":"James","cascade":"tjames","loc":"res","place":"home", "day0":"0,1,2,3,"}"; var getDay = data.day0; var getDayArray = getDay.split(","); ``` Essentially, I'm trying to get day0, which is 0,1,2,3, and turn it into an array with a structure of ``` [0] = 0 [1] = 1 [2] = 2 [3] = 3 ``` What is the best way to go about doing this?

Original source