Parse JSON string into an array

前端 未结 3 1686
别那么骄傲
别那么骄傲 2021-01-03 04:52

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         


        
3条回答
  •  一生所求
    2021-01-03 05:37

    This is built into most modern browser JavaScript engines. Depending on what environment you are targeting you can simply do:

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

    It's pretty simple. If you are targeting environments that don't have access to a built in JSON object you should try this JSON project.

提交回复
热议问题