我们如何在jquery中获取json代码的值

时间:2015-03-24 08:13:24

标签: json

我使用ajax发送数据并返回json代码。如何获取每个Name键的值。以下是我的代码: -

[{"Name":"Calendar","EmailTemplates":[],
"Href":"http://amt-ars-d.sevenverbs.com/api/v1/emailtemplategroups/1"},
{"Name":"Products","EmailTemplates":[],
"Href":"http://amt-ars-d.sevenverbs.com/api/v1/emailtemplategroups/2"},
{"Name":"Personal Events","EmailTemplates":[],
"Href":"http://amt-ars-d.sevenverbs.com/api/v1/emailtemplategroups/3"},
{"Name":"Health Tips","EmailTemplates":[],"Href":"http://amt-ars-d.sevenverbs.com/api/v1/emailtemplategroups/4"},
{"Name":"Financial Tips ","EmailTemplates":[],"Href":"http://amt-ars-d.sevenverbs.com/api/v1/emailtemplategroups/5"}]

我想要这个输出: 砑光机 Procudt

1 个答案:

答案 0 :(得分:0)

试试这个,

var x = eval(YourJsonInput);

for(var i=0; i<x.length; i++)
{
        var name = x[i].Name; //Here you get the name
        var link = x[i].Href; //Here you get the href
}