将json数组转换为object

时间:2013-05-27 08:03:50

标签: javascript jquery json

我有一个json数组

 jsoncast_arr = new array();
 jsoncast_arr.push( value +":"+ value1 );


 ["C :1b3ea8fa-89e9-4dc4-8e95-7ee9575cc391", "C :ed5817e6-3bfe-4bcf-9631-
 d091fc3a2d3b", "C :8c43b885-e6cd-457c-bf1d-4475f85b905f", "C :cf0eecd3-9bf1-4435-
 b6be-50da8b09662b", "C :74efc501-21b5-49d9-b95c-17549ccda8dc", "C :ecb67dfb-
 2d3c-4aea-9072-5339df4955a2", "C :c1f2faa6-49ba-4dbb-bea9-08eb1ffd426d", "C 
 :06fe9afb-1850-4470-b365-2318d995a647", "C :fa5f274d-fd6c-4904-b3d6-c20edf45efdf"]

当我解析json时,我需要将其转换成这样的,可能是javascript中的json对象

{"c"=>"1b3ea8fa-89e9-4dc4-8e95-7ee9575cc391","c"=>"ed5817e6-3bfe-4bcf-9631-
d091fc3a2d3b"}

这里JSON.stringify(jsoncast_arr)没有达到这个水平。

1 个答案:

答案 0 :(得分:0)

也许你想要一个对象数组:

[
{"c":"1b3ea8fa-89e9-4dc4-8e95-7ee9575cc391"},
{"c":"ed5817e6-3bfe-4bcf-9631-d091fc3a2d3b"}
]