我正在使用以下脚本从 groupon 的 api 中提取交易并将它们放在我的 html 页面中,但我无法从数组或循环中的 json 文件中提取数据或其他任何内容
$(function () {
$.getJSON("https://api.groupon.com/v2/deals.json?callback=?",
{
client_id: "b252ad3634a4ab2985b79d230ccc4e49a3ea9d19",
show: "all",
division_id: "los-angeles"
})
.done(function (data) {
console.log(data);
// do whatever processing you need to do to the data
// right here, then drop it in the div
$.each(data.deals, function (i, v) {
$img = $("<img/>", {
src: v.mediumImageUrl
});
$title = $("<div/>", {
html: v.title,
class: "dealName"
});
$price = $("<div/>", {
html: v.options.price,
class: "price"
});
$deal = $("<div/>", {
html: v.textAd,
class: "dealSmall"
});
$(".deals").append($deal);
$deal.prepend($img,$title,$price);
});
});
});
我需要获取选项内的价格,提前谢谢
json数据
{
"deals": [
{
"type": "groupon",
"textAd": {
"headline": "",
"line2": "",
"line1": ""
},
"finePrint": "Limit 1 per household, may buy 5 additional as gifts. Must activate by expiration date on Groupon, membership expires 12 months from activation date. Online redemption required. New clients only. Must be 18 or older. Must use promotional value in 1 visit.",
"smallImageUrl": "https://img.grouponcdn.com/deal/bv8yY9tnX1mTwddFDRN/fJ-440x267/v1/t50x50.jpg",
"locationNote": "",
"isMerchandisingDeal": false,
"division": {
"timezoneOffsetInSeconds": -25200,
"lng": -118.243,
"timezoneIdentifier": "America/Los_Angeles",
"name": "Los Angeles",
"lat": 34.0522,
"id": "los-angeles",
"timezone": "Pacific Time (US & Canada)"
},
"status": "open",
"soldQuantityMessage": "80+",
"limitedQuantityRemaining": null,
"grouponRating": null,
"grid4ImageUrl": "https://img.grouponcdn.com/deal/bv8yY9tnX1mTwddFDRN/fJ-440x267/v1/t300x182.jpg",
"vip": "",
"salesforceLink": "https://login.salesforce.com/006C000000jiCfiIAE",
"areas": [
{
"name": "Los Angeles",
"id": "los-angeles"
},
{
"name": "San Gabriel Valley",
"id": "san-gabriel-valley"
},
{
"name": "San Fernando Valley",
"id": "san-fernando-valley"
}
],
"mediumImageUrl": "https://img.grouponcdn.com/deal/bv8yY9tnX1mTwddFDRN/fJ-440x267/v1/t100x100.jpg",
"tippingPoint": 0,
"highlightsHtml": "<p>Members snag pairs of free tickets at whim from a database of concert, theater, museum, and sporting events that haven't yet sold out</p>",
"dealTypes": [
{
"description": "Live sports, music, and theater events",
"name": "Will Call",
"id": "will-call"
}
],
"announcementTitle": "Half Off Event-Access Membership for Two",
"title": "$40 for a One-Year Event-Access Membership for Two from Fillaseat ($79.95 Value)",
"isNowDeal": false,
"tippedAt": "2013-08-13T07:12:31Z",
"startAt": "2013-08-14T07:00:00Z",
"pitchHtml": "<p>Seeing a live performance is an exciting, ever-changing interaction between you, the performer, and the stranger whose lighter you keep stealing. Make connections with this Groupon.</p>\n\n<h4>$40 for a One-Year Event-Access Membership for Two ($79.95 Value)</h4>\n\n<p>A one-year membership provides twosomes with free seats at Los Angeles shows, concerts, and sporting events that have not yet sold out. Tickets can be claimed on a first-come, first-served basis—members simply visit the website to browse available events and, once they've selected an event they'd like to attend, they'll reserve a pair of tickets. Members can expect to find several events available each week, and are welcome to reserve up to two tickets for every posted event. See the <a href="http://www.fillaseatla.com/memrule.php">full list of rules</a> that apply to members.<p></p>",
"isOptionListComplete": true,
"channels": [],
"accessType": "featured",
"grid6ImageUrl": "https://img.grouponcdn.com/deal/bv8yY9tnX1mTwddFDRN/fJ-440x267/v1/t460x279.jpg",
"says": {
"websiteContent": "<div style="margin-top: -30px">\r\n<img src="http://s3.grouponcdn.com/images/humor_service/groupon_says/gizmos/email-gizmo-image-1376335702-DEM_Umami.jpg" alt="Umami" />\r\n</div>\r\n\r\n",
"emailContent": "Which foods taste like an anti-sweet, salty tongue-treat? Click here to find out. ",
"title": "Umami",
"websiteContentHtml": "<div style="margin-top: -30px">\n<img src="http://s3.grouponcdn.com/images/humor_service/groupon_says/gizmos/email-gizmo-image-1376335702-DEM_Umami.jpg" alt="Umami" />\n</div>\n\n\n",
"emailContentHtml": "<p>Which foods taste like an anti-sweet, salty tongue-treat? Click here to find out.</p>",
"id": "umami"
},
"merchant": {
"websiteUrl": "http://www.fillaseatla.com",
"ratings": [],
"name": "Fillaseat",
"id": "fillaseat-la"
},
"isTipped": true,
"endAt": "2013-08-19T06:59:59Z",
"dealUrl": "http://www.groupon.com/deals/fillaseat-la-2",
"sidebarImageUrl": "https://img.grouponcdn.com/deal/bv8yY9tnX1mTwddFDRN/fJ-440x267/v1/t200x300.jpg",
"displayOptions": [
{
"enabled": true,
"name": "timer"
},
{
"enabled": true,
"name": "quantity"
},
{
"enabled": true,
"name": "discount"
}
],
"placementPriority": "nearby",
"uuid": "f4c72216-fddd-11e2-8117-0025906a929e",
"tags": [
{
"name": "Arts and Entertainment"
}
],
"soldQuantity": 80,
"shippingAddressRequired": false,
"isTravelBookableDeal": false,
"placeholderUrl": "https://secure-assets.grouponcdn.com/images/groupon/grayPlaceholder.png",
"id": "fillaseat-la-2",
"redemptionLocation": "Online Deal",
"options": [
{
"expiresInDays": null,
"buyUrl": "https://www.groupon.com/deals/fillaseat-la-2/confirmation?pledge_id=7994510",
"maximumPurchaseQuantity": 6,
"discountPercent": 50,
"status": "open",
"soldQuantityMessage": "80+",
"price": {
"formattedAmount": "$40.00",
"amount": 4000,
"currencyCode": "USD"
},
"externalUrl": null,
"minimumPurchaseQuantity": 1,
"value": {
"formattedAmount": "$79.95",
"amount": 7995,
"currencyCode": "USD"
},
"initialQuantity": 0,
"title": "One duet membership",
"redemptionLocations": [],
"specificAttributes": {},
"details": [
{
"description": "Limit 1 per household, may buy 5 additional as gifts. Must activate by expiration date on Groupon, membership expires 12 months from activation date. Online redemption required. New clients only. Must be 18 or older. Must use promotional value in 1 visit."
}
],
"bookable": false,
"remainingQuantity": 0,
"endAt": "2013-08-19T06:59:59Z",
"discount": {
"formattedAmount": "$39.95",
"amount": 3995,
"currencyCode": "USD"
},
"isLimitedQuantity": true,
"customFields": [],
"soldQuantity": 80,
"expiresAt": "2013-11-14T07:59:59Z",
"id": 7994510,
"isSoldOut": false
}
],
"isSoldOut": false,
"isAutoRefundEnabled": false,
"shortAnnouncementTitle": "Event-Access Membership for Two",
"largeImageUrl": "https://img.grouponcdn.com/deal/bv8yY9tnX1mTwddFDRN/fJ-440x267/v1/t440x300.jpg"
},