这是我的JSON,我正在尝试提取第二个campaigns->settings->subject_line
对象。这是我的JSON:
{
"campaigns":[
{
"id":"xxxxx",
"type":"regular",
"create_time":"2015-07-09T08:08:17+00:00",
"archive_url":"http://eepurl.com/xxxxxx",
"status":"sent",
"emails_sent":1,
"send_time":"2015-07-09T08:11:31+00:00",
"content_type":"template",
"recipients":{
"list_id":"2753cf8604",
"segment_opts":{
"match":"any",
"conditions":[
{
"field":"EMAIL",
"op":"is",
"value":"xxxxx@outlook.com"
}
]
}
},
"settings":{
"subject_line":"asdasd - visioni sonore",
"title":"asdad - visioni sonore",
"from_name":"Luca ",
"reply_to":"info@luca-.com",
"use_conversation":false,
"to_name":"*|FNAME|*",
"folder_id":0,
"authenticate":true,
"auto_footer":false,
"inline_css":false,
"auto_tweet":false,
"fb_comments":false,
"timewarp":false,
"template_id":60145,
"drag_and_drop":true
},
"tracking":{
"opens":true,
"html_clicks":true,
"text_clicks":true,
"goal_tracking":false,
"ecomm360":false,
"google_analytics":"",
"clicktale":""
},
"report_summary":{
"opens":1,
"unique_opens":1,
"open_rate":1,
"clicks":0,
"subscriber_clicks":0,
"click_rate":0
},
"delivery_status":{
"enabled":false
},
"_links":[
{
"rel":"parent",
"href":"https://us11.api.mailchimp.com/3.0/campaigns",
"method":"GET",
"targetSchema":"https://us11.api.mailchimp.com/schema/3.0/Campaigns/Collection.json"
},
{
"rel":"self",
"href":"https://us11.api.mailchimp.com/3.0/campaigns/51aa8bda6b",
"method":"GET",
"targetSchema":"https://us11.api.mailchimp.com/schema/3.0/Campaigns/Instance.json"
},
{
"rel":"delete",
"href":"https://us11.api.mailchimp.com/3.0/campaigns/xxxxx",
"method":"DELETE"
},
{
"rel":"cancel_send",
"href":"https://us11.api.mailchimp.com/3.0/campaigns/xxxx/actions/cancel-send",
"method":"POST"
},
{
"rel":"feedback",
"href":"https://us11.api.mailchimp.com/3.0/campaigns/51aa8bda6b/feedback",
"method":"GET",
"targetSchema":"https://us11.api.mailchimp.com/schema/3.0/Campaigns/Feedback/Collection.json"
}
]
},
{
"id":"xxxxx",
"type":"regular",
"create_time":"2015-07-09T08:05:08+00:00",
"archive_url":"http://eepurl.com/xxxx",
"status":"sent",
"emails_sent":1,
"send_time":"2015-07-09T08:08:08+00:00",
"content_type":"template",
"recipients":{
"list_id":"2753cf8604",
"segment_opts":{
"match":"any",
"conditions":[
{
"field":"EMAIL",
"op":"is",
"value":"luca@outlook.com"
}
]
}
},
"settings":{
"subject_line":"Carri\u00e9res de Lumi\u00e9res - colonna sonora",
"title":"Carri\u00e9res de Lumi\u00e9res - colonna sonora",
"from_name":"Luca ",
"reply_to":"info@luca-.com",
"use_conversation":false,
"to_name":"*|FNAME|*",
"folder_id":0,
"authenticate":true,
"auto_footer":false,
"inline_css":false,
"auto_tweet":false,
"fb_comments":false,
"timewarp":false,
"template_id":60145,
"drag_and_drop":true
},
"tracking":{
"opens":true,
"html_clicks":true,
"text_clicks":true,
"goal_tracking":false,
"ecomm360":false,
"google_analytics":"",
"clicktale":""
},
"report_summary":{
"opens":1,
"unique_opens":1,
"open_rate":1,
"clicks":0,
"subscriber_clicks":0,
"click_rate":0
},
"delivery_status":{
"enabled":false
},
"_links":[
{
"rel":"parent",
"href":"https://us11.api.mailchimp.com/3.0/campaigns",
"method":"GET",
"targetSchema":"https://us11.api.mailchimp.com/schema/3.0/Campaigns/Collection.json"
},
{
"rel":"self",
"href":"https://us11.api.mailchimp.com/3.0/campaigns/xxxxx",
"method":"GET",
"targetSchema":"https://us11.api.mailchimp.com/schema/3.0/Campaigns/Instance.json"
},
{
"rel":"delete",
"href":"https://us11.api.mailchimp.com/3.0/campaigns/xxxxx",
"method":"DELETE"
},
{
"rel":"cancel_send",
"href":"https://us11.api.mailchimp.com/3.0/campaigns/xxxx/actions/cancel-send",
"method":"POST"
},
{
"rel":"feedback",
"href":"https://us11.api.mailchimp.com/3.0/campaigns/xxxxx/feedback",
"method":"GET",
"targetSchema":"https://us11.api.mailchimp.com/schema/3.0/Campaigns/Feedback/Collection.json"
}
]
},
{
"id":"71392a197e",
"type":"regular",
"create_time":"2015-07-09T07:59:18+00:00",
"archive_url":"http://eepurl.com/xxxx",
"status":"sent",
"emails_sent":1,
"send_time":"2015-07-09T08:04:58+00:00",
"content_type":"template",
"recipients":{
"list_id":"2753cf8604",
"segment_opts":{
"match":"any",
"conditions":[
{
"field":"EMAIL",
"op":"is",
"value":"luca@outlook.com"
}
]
}
},
"settings":{
"subject_line":"Yerma",
"title":"Yerma",
"from_name":"Luca ",
"reply_to":"info@luca-.com",
"use_conversation":false,
"to_name":"*|FNAME|*",
"folder_id":0,
"authenticate":true,
"auto_footer":false,
"inline_css":false,
"auto_tweet":false,
"fb_comments":false,
"timewarp":false,
"template_id":60145,
"drag_and_drop":true
},
"tracking":{
"opens":true,
"html_clicks":true,
"text_clicks":true,
"goal_tracking":false,
"ecomm360":false,
"google_analytics":"",
"clicktale":""
},
"report_summary":{
"opens":1,
"unique_opens":1,
"open_rate":1,
"clicks":0,
"subscriber_clicks":0,
"click_rate":0
},
"delivery_status":{
"enabled":false
},
"_links":[
{
"rel":"parent",
"href":"https://us11.api.mailchimp.com/3.0/campaigns",
"method":"GET",
"targetSchema":"https://us11.api.mailchimp.com/schema/3.0/Campaigns/Collection.json"
},
{
"rel":"self",
"href":"https://us11.api.mailchimp.com/3.0/campaigns/71392a197e",
"method":"GET",
"targetSchema":"https://us11.api.mailchimp.com/schema/3.0/Campaigns/Instance.json"
},
{
"rel":"delete",
"href":"https://us11.api.mailchimp.com/3.0/campaigns/71392a197e",
"method":"DELETE"
},
{
"rel":"cancel_send",
"href":"https://us11.api.mailchimp.com/3.0/campaigns/xxxx/actions/cancel-send",
"method":"POST"
},
{
"rel":"feedback",
"href":"https://us11.api.mailchimp.com/3.0/campaigns/71392a197e/feedback",
"method":"GET",
"targetSchema":"https://us11.api.mailchimp.com/schema/3.0/Campaigns/Feedback/Collection.json"
}
]
}
],
"total_items":3,
"_links":[
{
"rel":"parent",
"href":"https://us11.api.mailchimp.com/3.0/",
"method":"GET",
"targetSchema":"https://us11.api.mailchimp.com/schema/3.0/Root.json"
},
{
"rel":"self",
"href":"https://us11.api.mailchimp.com/3.0/campaigns",
"method":"GET",
"targetSchema":"https://us11.api.mailchimp.com/schema/3.0/Campaigns/Collection.json"
}
]
}
我试过这个但没有任何反应:
$("#secondresult").html(data[0].campaigns.settings.subject_line);
我还需要将对象u00e9
中的Carri\u00e9res de Lumi\u00e9res - colonna sonora
转换为UTF-8
答案 0 :(得分:0)
取决于JSON,您提供此功能
$("#secondresult").html(data.campaigns[0].settings.subject_line);
您正在调用数据(对象不是数组)和广告系列(js数组不是对象)