有没有可能的方法将Stringify转换为Object of Array

时间:2016-05-03 03:11:23

标签: javascript angularjs

"[{"poll_watcher_id":5,"precinct_id":"","candidate_id":1,"count":"123"},
  {"poll_watcher_id":5,"precinct_id":"","candidate_id":9},
  {"poll_watcher_id":5,"precinct_id":"","candidate_id":6},
  {"poll_watcher_id":5,"precinct_id":"","candidate_id":3},
  {"poll_watcher_id":5,"precinct_id":"","candidate_id":7},
  {"poll_watcher_id":5,"precinct_id":"","candidate_id":4}]"

这个输出只是一个字符串,我想要的是将它转换为对象数组供我使用此输出中的数据

2 个答案:

答案 0 :(得分:7)

在字符串上使用JSON.parse

答案 1 :(得分:-1)

反序列化JSON字符串使用

angular.fromJson(JSON);

angularjs.org