在javascript或jquery中解析Json [英] Parse Json in javascript or jquery
本文介绍了在javascript或jquery中解析Json的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
可能重复:
如何在javascript中解析json
Possible Duplicate:
how to parse json in javascript
我需要在JavaScript或jQuery中解析此JSON.请帮助我获取下面JSON中的产品列表.
I need to parse this JSON in JavaScript or jQuery. Please help me in getting the list of product in the below JSON.
获取产品列表
{
"main": {
"ProductsData": {
"Product": {
"AdjustmentTypeID": "0",
"BrandID": "4",
"BrandName": "Joseph Joseph",
"ChildrenGenerated": "False",
"Cost": "8.50",
"Description": "<span style=\"line-height: 120%; \">The ingenious dual-chamber design of this measuring jug eliminates the need for separate measuring spoons, cups and jugs. Use the small chamber to accurately measure liquids from as little as a single teaspoon (5ml), and then for greater volumes (up to 550ml) simply turn the jug 180º and use the larger chamber. Made from SAN material. Heat resistant to 90°C \\/ 190°F.<\\/span>\\u000d\\u000a<p class=\"MsoNormal\" style=\"margin-bottom:0cm;margin-bottom:.0001pt;line-height:\\u000d\\u000a120%;mso-layout-grid-align:none;text-autospace:none;vertical-align:middle\"><br \\/>\\u000d\\u000aDesign registered<span lang=\"EN-US\"><o:p><\\/o:p><\\/span><\\/p>\\u000d\\u000a<p class=\"BasicParagraph\"><span style=\"font-size:11.0pt;line-height:120%;\\u000d\\u000afont-family:"Calibri","sans-serif";color:windowtext\"><br \\/>\\u000d\\u000aDimensions 7x 7 x 15cm<o:p><\\/o:p><\\/span><\\/p>",
"DownloadFile": "",
"InternalCode": "502842009381 0",
"IsProductActive": "False",
"ManufacturerID": "11",
"ManufacturerName": "Joseph Joseph",
"OptionMatchGroupID": "",
"ParentProduct": "",
"ProductID": "80",
"ProductName": "2-in-1 Measuring Jug",
"ProductTypeDescription": "Compound Product",
"ProductTypeID": "8",
"SiteID": "57",
"StockLevel": "",
"SupplierID": "3",
"SupplierName": "Joseph Joseph",
"UseStockControl": "False",
"VatRate": "20"
}
}
}
}
推荐答案
使用 parseJSON
方法在jQuery中.
Use the parseJSON
method in jQuery.
示例:
var obj = $.parseJSON(yourJsonString);
alert(obj.main.ProductsData.Product.Cost);
这篇关于在javascript或jquery中解析Json的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文