我已经解析了一个看起来像这样的JSON,如何从中获取版本号和许可证详细信息?
'[ { id: 20,
version_number: '1.0',
programming_lang: 'Not available',
primary_contact: 'Not available',
technical_contact: 'Not available',
link: null,
status: 'APPROVED',
description: '<b><font color=#1241cc>Support SPOC: </font></b>Leo RD LIU, <b><font color=#1241cc>Used by: </font></b>Not Specified',
src_id: 7757,
legal_description: 'Not available',
component_size: 'SMALL',
createdAt: '2016-12-21T00:00:00.000Z',
updatedAt: '2017-03-10T11:47:12.000Z',
component_id: 20,
created_by: 1,
component_licenses: [] } ]'
答案 0 :(得分:2)
您可以使用此代码:
for(var i in arr){
console.log(arr[i].version_number);
}
答案 1 :(得分:1)
JSON.parse(yourJson)[0].version_number
答案 2 :(得分:0)
如果要将整个json对象转换为javascript对象,可以使用
//By using jquery json parser
var obj = $.parseJSON('{"name": "", "skills": "", "jobtitel": "Entwickler", "res_linkedin": "GwebSearch"}');
alert(obj['jobtitel']);
//By using javasript json parser
var t = JSON.parse('{"name": "", "skills": "", "jobtitel": "Entwickler", "res_linkedin": "GwebSearch"}');
alert(t['jobtitel'])
对于您可以使用的任何特定键值对:
var data = {"name": "", "skills": "", "jobtitel": "Entwickler", "res_linkedin": "GwebSearch"}
var parsedData = JSON.parse(data);
alert(parsedData.name);
alert(parsedData.skills);
alert(parsedData.jobtitel);
alert(parsedData.res_linkedin);