这个JSON我没有在PHP Json_decode上工作,它返回NULL,当我将精确的JSON放在网站http://jsonformatter.curiousconcept.com/#jsonformatter中时 它说它有效并且工作得很好。
$json = <<<START
{"currentUserScreenName":"tatXtxt","recentPlaces":[],"cdnBase":{"versioned":{"ssl":["https:\/\/si0.twimg.com\/a\/1309465578"],"http":["http:\/\/a0.twimg.com\/a\/1309465578","http:\/\/a1.twimg.com\/a\/1309465578","http:\/\/a2.twimg.com\/a\/1309465578","http:\/\/a3.twimg.com\/a\/1309465578"]},"unversioned":{"ssl":["https:\/\/si0.twimg.com"],"http":["http:\/\/a0.twimg.com","http:\/\/a1.twimg.com","http:\/\/a2.twimg.com","http:\/\/a3.twimg.com"]}},"pageLocaleJS":"http:\/\/a3.twimg.com\/a\/1309465578\/javascripts\/phoenix\/i18n\/pt.js","becameUser":false,"payload":{"profiling":false,"conditionalTemplates":{}},"isNarrow":true,"deciderFeatures":{"tweet_stream_list":1,"geo_location":1,"people_stream_friends":1,"tweet_stream_favorites":1,"promo_component":1,"phoenix_local_gowalla":1,"new_trends_location_selector":1,"geo_ui":1,"flock":1,"phoenix_geo_v4":1,"geo_ui_dropdown_available":1,"tweet_stream_mentions_polling":1,"contact_import_stream":1,"html5Routing":1,"list_stream_memberships":1,"phoenix_frontpage_rotate_avatars":1,"tweet_stream_retweets_by_you":1,"inline_media_component":1,"whotofollow_random_sample":1,"phoenix_sandboxed_ajax":1,"tweet_stream_following_polling":1,"whotofollow_recommendations":1,"phoenix_first_time":1,"list_stream_own_lists":1,"phoenix_facets_logged_out":1,"phoenix_amazon_details":1,"in_reply_to_component":1,"sync_scribe":1,"geo_show_similar_places":1,"phoenix_turkey_permalink":1,"tweet_streams_polling":1,"media_flagging":1,"phoenix_search_relevance_logged_out":1,"user_shuffler":1,"mobile_download_gallery_logged_out":1,"phoenix_aol_video":1,"logged_out_people_search":1,"social_context":1,"email_device_settings":1,"people_streams":1,"tweet_stream_user_polling":1,"tweet_stream_retweets_by_you_polling":1,"people_stream_people_search":1,"phoenix_local_plancast":1,"scribe_client_event":1,"tweet_streams":1,"profile_combined_api":1,"tweet_stream_user":1,"phoenix_facets_videos":1,"phoenix_instagram_and_friends":1,"tweet_geo_component":1,"tweet_stream_mentions":1,"phoenix_tweetbox_talon":1,"phoenix_scribe":1,"phoenix_local_meetup":1,"tweet_stream_search":1,"phoenix_facets":1,"dashboard_activity_following":1,"retweeters_component":1,"people_stream_list_followers":1,"more_lists_component":1,"mt_tweet_backend_bing":1,"phoenix_talon_on_copy":1,"place_users_stream":1,"message_stream":1,"tweet_stream_home":1,"phoenix_autocomplete_place_trigger_words":1,"dashboard_activity_favorites":1,"dashboard_activity_listed":1,"list_streams":1,"tweet_stream_your_tweets_retweeted_polling":1,"phoenix_local_foursquare":1,"phoenix_puffin":1,"tweet_stream_list_polling":1,"tweet_stream_retweets_by_others":1,"phoenix_search_dropdown":1,"people_stream_follower_requests":1,"tweet_stream_home_polling":1,"trends_component":1,"phoenix_search_relevance":1,"tweet_stream_your_tweets_retweeted":1,"phoenix_pretty_links":1,"local_trends":1,"place_people_component":1,"people_stream_list_members":1,"place_tweets_component":1,"dashboard_activity_followers":1,"following_page_tweets_tab":1,"list_stream_subscriptions":1,"tweet_stream_retweets_by_others_polling":1,"mobile_download_gallery":1,"geo_more_places":1,"japanese_ad_component":1,"infinite_scroll":1,"tweet_stream_search_polling":1,"whotofollow_similarities":1,"people_stream_followers":1,"recent_tweets_component":1,"tweet_stream_favorites_polling":1,"welcome_warm_signup":1,"geo_allow_set_location_manually":1,"promptbird_phoenix":1,"phoenix_facets_images":1,"promoted_accounts_in_whotofollow_viewall":1,"suggestion_categories_streams":1,"geo_place_creation":1,"conversations":1,"tweet_stream_following":1,"phoenix_autocomplete":1,"onebox_user_search":1,"advanced_search":1,"i18n_new_translation_center":1,"fake_loggedout_decider":1,"newest_list_members_component":1},"adminRights":false,"isPreflight":false,"languages":[{"css_classes":"western pt","name":"Portugu\u00eas","code":"pt","name_en":"Portuguese"},{"css_classes":"western it","name":"Italiano","code":"it","name_en":"Italian"},{"css_classes":"western es","name":"Espa\u00f1ol","code":"es","name_en":"Spanish"},{"css_classes":"western tr","name":"T\u00fcrk\u00e7e","code":"tr","name_en":"Turkish"},{"css_classes":null,"name":"English","code":"en","name_en":"English"},{"css_classes":"asian ko","name":"\ud55c\uad6d\uc5b4","code":"ko","name_en":"Korean"},{"css_classes":"western fr","name":"fran\u00e7ais","code":"fr","name_en":"French"},{"css_classes":"western ru","name":"\u0420\u0443\u0441\u0441\u043a\u0438\u0439","code":"ru","name_en":"Russian"},{"css_classes":"western de","name":"Deutsch","code":"de","name_en":"German"},{"css_classes":"asian ja","name":"\u65e5\u672c\u8a9e","code":"ja","name_en":"Japanese"}],"abBuckets":{"remember_me_on_signup_83":{"bucket":"experiment","version":9,"experiment_key":"remember_me_on_signup_83","bucket_names":["control","experiment"]},"Contact_Import_Images-40":{"bucket":"control","version":3,"experiment_key":"Contact_Import_Images-40","bucket_names":["control","images"]},"Contact_Import_Services-39":{"bucket":"control","version":4,"experiment_key":"Contact_Import_Services-39","bucket_names":["control","vertical","vertical_matched"]},"welcome_flow_addressbook_81":{"bucket":"control","version":8,"experiment_key":"welcome_flow_addressbook_81","bucket_names":["control","addressbook"]},"Relevance_V1-49":{"bucket":"control","version":10,"experiment_key":"Relevance_V1-49","bucket_names":["control","recent"]}},"pageLocaleClass":"western pt","pageLocale":"pt","globalConfig":{"photo_sizes":{"large":{"h":2048,"resize":"fit","w":1024},"medium":{"h":1200,"resize":"fit","w":600},"thumb":{"h":150,"resize":"crop","w":150},"small":{"h":480,"resize":"fit","w":340}},"non_username_paths":["about","account","accounts","activity","all","announcements","anywhere","api_rules","api_terms","apirules","apps","auth","badges","blog","business","buttons","contacts","devices","direct_messages","download","downloads","edit_announcements","faq","favorites","find_sources","find_users","followers","following","friend_request","friendrequest","friends","goodies","help","home","im_account","inbox","invitations","invite","jobs","list","login","logout","me","mentions","messages","newtwitter","notifications","nudge","oauth","phoenix_search","positions","privacy","public_timeline","related_tweets","replies","retweeted_of_mine","retweets","retweets_by_others","rules","saved_searches","search","sent","settings","share","signup","signin","similar_to","statistics","terms","tos","translate","trends","tweetbutton","twttr","update_discoverability","users","welcome","who_to_follow","widgets","zendesk_auth","media_signup","phoenix_qunit_tests"],"max_media_per_upload":1,"short_url_length_https":20,"characters_reserved_per_media":20,"photo_size_limit":3145728,"short_url_length":19},"requestCacheSeedData":[{"options":[{}],"json":{"profile_sidebar_border_color":"C0DEED","profile_background_tile":false,"profile_sidebar_fill_color":"DDEEF6","name":"Testando","created_at":"Fri Jul 01 11:10:49 +0000 2011","location":null,"profile_image_url":"http:\/\/a1.twimg.com\/sticky\/default_profile_images\/default_profile_2_normal.png","is_translator":false,"profile_link_color":"0084B4","id_str":"327319701","follow_request_sent":false,"contributors_enabled":false,"favourites_count":0,"states":{"pending_email":"testandoXXXX@hotmail.com","bouncing_email":["testandoXXXX@hotmail.com"],"detached_email":false,"suspended":false,"needs_employee_email_update":false},"url":null,"default_profile":true,"id":327319701,"utc_offset":null,"profile_image_url_https":"https:\/\/si0.twimg.com\/sticky\/default_profile_images\/default_profile_2_normal.png","profile_use_background_image":true,"listed_count":0,"lang":"pt","followers_count":0,"profile_text_color":"333333","protected":false,"profile_background_color":"C0DEED","profile_background_image_url_https":"https:\/\/si0.twimg.com\/images\/themes\/theme1\/bg.png","verified":false,"time_zone":null,"geo_enabled":false,"description":null,"notifications":false,"statuses_count":0,"default_profile_image":true,"friends_count":0,"profile_background_image_url":"http:\/\/a0.twimg.com\/images\/themes\/theme1\/bg.png","show_all_inline_media":false,"following":false,"screen_name":"tatXtxt"},"api_request_name":"account\/verify_credentials"},{"options":[{"include_available_features":1,"include_entities":1,"pc":true,"contributor_details":true}],"json":[],"api_request_name":"statuses\/home_timeline"},{"options":[{}],"json":{"sleep_time":{"end_time":null,"enabled":false,"start_time":null},"language":"pt","discoverable_by_email":true,"always_use_https":false,"geo_enabled":false},"api_request_name":"account\/settings"},{"options":[{"pc":true}],"json":{"trends":{"current_trends":[{"name":"#listentoyourheart","url":"http:\/\/search.twitter.com\/search?q=%23listentoyourheart"},{"name":"#youneedtositdown","url":"http:\/\/search.twitter.com\/search?q=%23youneedtositdown"},{"name":"Teddy Bautista","url":"http:\/\/search.twitter.com\/search?q=%22Teddy%20Bautista%22"},{"name":"#eqakl","url":"http:\/\/search.twitter.com\/search?q=%23eqakl"},{"name":"Mayor Duterte","url":"http:\/\/search.twitter.com\/search?q=%22Mayor%20Duterte%22"},{"name":"Brendon Urie","url":"http:\/\/search.twitter.com\/search?q=%22Brendon%20Urie%22"},{"name":"Mirror Mirror","url":"http:\/\/search.twitter.com\/search?q=%22Mirror%20Mirror%22"},{"name":"BTD","url":"http:\/\/search.twitter.com\/search?q=BTD"},{"name":"'Perfect Night'","url":"http:\/\/search.twitter.com\/search?q=%22'Perfect%20Night'%22"},{"name":"Black & White","url":"http:\/\/search.twitter.com\/search?q=%22Black%20&%20White%22"}]}},"api_request_name":"trends\/current"},{"options":[{}],"json":{"promo":{"name":"IOC Olympic Day (PT)","created_at":"Wed Jun 22 21:28:29 +0000 2011","promo_contents":"\u003Ca href=\"http:\/\/contest.olympic.org\/\" class=\"definition\" onClick=\"javascript: pageTracker._trackPageview('\/\ndefinition\/IOC_pt');\"\u003E\u003Cstrong\u003EDia Ol\u00edmpico no Twitter\u003C\/strong\u003E\u003C\/a\u003E Comemore o espir\u00edto dos Jogos Ol\u00edmpicos no Twitter e voc\u00ea poder\u00e1 ganhar uma viagem a Londres 2012.","promo_type":"","updated_at":"Thu Jun 23 17:00:45 +0000 2011","id":150,"is_sponsored":false,"is_active":true,"locale":"pt"}},"api_request_name":"promos\/random"}],"remoteIP":"189.104.75.181","appcacheRequiredMajorVersion":1,"userProperties":{"emailDiscoverabilitySet":true,"mobilePhoneDiscoverabilitySet":false,"deviceAddress":null,"discoverableByEmail":true,"discoverableByMobilePhone":false,"emailAddress":"null","deviceSetup":false},"currentUser":{"memberships_path":"\/tatXtxt\/lists\/memberships","rgba_tweet_border_color":"rgba(0,132,180,0.15)","linkified_status":"","rgba_sidebar_color":"rgba(221,238,246,0.9)","user_followers_path":"\/tatXtxt\/followers","screen_name_from_server":"tatXtxt","profile_image_url_from_server":"http:\/\/a1.twimg.com\/sticky\/default_profile_images\/default_profile_2_normal.png","rgba_newtweets_border_color":"rgba(0,132,180,0.25)","rgba_tweet_background_color":"rgba(0,132,180,0.1)","subscriptions_path":"\/tatXtxt\/lists\/subscriptions","user_favorites_path":"\/tatXtxt\/favorites","profile_path":"\/tatXtxt","id":327319701,"rgba_newtweets_background_color":"rgba(0,132,180,0.2)","lists_path":"\/tatXtxt\/lists","rgba_text_color":"rgba(51,51,51,0.6)","user_following_path":"\/tatXtxt\/following","latest_timestamp":"","account_profile_image_path":"\/account\/profile_image\/tatXtxt","bigger_profile_image_url":"http:\/\/a1.twimg.com\/sticky\/default_profile_images\/default_profile_2.png"},"requestFullCity":"br,05,feira_de_santana","postAuthenticityToken":"3de1b517590cad537393d7c2999d024524c8b492","isAdmin":false}
START;
print_r(json_decode($json));
提前谢谢
答案 0 :(得分:1)
PHP解析脚本中的字符串(heredoc)文字。并且\可能具有特殊含义,具体取决于后面的字符。如果您想在字符串中添加\
,则应该/必须在文字中写\\
$json = <<<START
{"currentUserScreenName":"tatXtxt","recentPlaces":[],"cdnBase":{"versioned":{"ssl":["https:\\/\\/si0.twimg.com\\/a\\/1309465578"],"http":["http:\\/\\/a0.twimg.com\\/a\\/1309465578","http:\\/\\/a1.twimg.com\\/a\\/1309465578","http:\\/\\/a2.twimg.com\\/a\\/1309465578","http:\\/\\/a3.twimg.com\\/a\\/1309465578"]},"unversioned":{"ssl":["https:\\/\\/si0.twimg.com"],"http":["http:\\/\\/a0.twimg.com","http:\\/\\/a1.twimg.com","http:\\/\\/a2.twimg.com","http:\\/\\/a3.twimg.com"]}},"pageLocaleJS":"http:\\/\\/a3.twimg.com\\/a\\/1309465578\\/javascripts\\/phoenix\\/i18n\\/pt.js","becameUser":false,"payload":{"profiling":false,"conditionalTemplates":{}},"isNarrow":true,"deciderFeatures":{"tweet_stream_list":1,"geo_location":1,"people_stream_friends":1,"tweet_stream_favorites":1,"promo_component":1,"phoenix_local_gowalla":1,"new_trends_location_selector":1,"geo_ui":1,"flock":1,"phoenix_geo_v4":1,"geo_ui_dropdown_available":1,"tweet_stream_mentions_polling":1,"contact_import_stream":1,"html5Routing":1,"list_stream_memberships":1,"phoenix_frontpage_rotate_avatars":1,"tweet_stream_retweets_by_you":1,"inline_media_component":1,"whotofollow_random_sample":1,"phoenix_sandboxed_ajax":1,"tweet_stream_following_polling":1,"whotofollow_recommendations":1,"phoenix_first_time":1,"list_stream_own_lists":1,"phoenix_facets_logged_out":1,"phoenix_amazon_details":1,"in_reply_to_component":1,"sync_scribe":1,"geo_show_similar_places":1,"phoenix_turkey_permalink":1,"tweet_streams_polling":1,"media_flagging":1,"phoenix_search_relevance_logged_out":1,"user_shuffler":1,"mobile_download_gallery_logged_out":1,"phoenix_aol_video":1,"logged_out_people_search":1,"social_context":1,"email_device_settings":1,"people_streams":1,"tweet_stream_user_polling":1,"tweet_stream_retweets_by_you_polling":1,"people_stream_people_search":1,"phoenix_local_plancast":1,"scribe_client_event":1,"tweet_streams":1,"profile_combined_api":1,"tweet_stream_user":1,"phoenix_facets_videos":1,"phoenix_instagram_and_friends":1,"tweet_geo_component":1,"tweet_stream_mentions":1,"phoenix_tweetbox_talon":1,"phoenix_scribe":1,"phoenix_local_meetup":1,"tweet_stream_search":1,"phoenix_facets":1,"dashboard_activity_following":1,"retweeters_component":1,"people_stream_list_followers":1,"more_lists_component":1,"mt_tweet_backend_bing":1,"phoenix_talon_on_copy":1,"place_users_stream":1,"message_stream":1,"tweet_stream_home":1,"phoenix_autocomplete_place_trigger_words":1,"dashboard_activity_favorites":1,"dashboard_activity_listed":1,"list_streams":1,"tweet_stream_your_tweets_retweeted_polling":1,"phoenix_local_foursquare":1,"phoenix_puffin":1,"tweet_stream_list_polling":1,"tweet_stream_retweets_by_others":1,"phoenix_search_dropdown":1,"people_stream_follower_requests":1,"tweet_stream_home_polling":1,"trends_component":1,"phoenix_search_relevance":1,"tweet_stream_your_tweets_retweeted":1,"phoenix_pretty_links":1,"local_trends":1,"place_people_component":1,"people_stream_list_members":1,"place_tweets_component":1,"dashboard_activity_followers":1,"following_page_tweets_tab":1,"list_stream_subscriptions":1,"tweet_stream_retweets_by_others_polling":1,"mobile_download_gallery":1,"geo_more_places":1,"japanese_ad_component":1,"infinite_scroll":1,"tweet_stream_search_polling":1,"whotofollow_similarities":1,"people_stream_followers":1,"recent_tweets_component":1,"tweet_stream_favorites_polling":1,"welcome_warm_signup":1,"geo_allow_set_location_manually":1,"promptbird_phoenix":1,"phoenix_facets_images":1,"promoted_accounts_in_whotofollow_viewall":1,"suggestion_categories_streams":1,"geo_place_creation":1,"conversations":1,"tweet_stream_following":1,"phoenix_autocomplete":1,"onebox_user_search":1,"advanced_search":1,"i18n_new_translation_center":1,"fake_loggedout_decider":1,"newest_list_members_component":1},"adminRights":false,"isPreflight":false,"languages":[{"css_classes":"western pt","name":"Portugu\\u00eas","code":"pt","name_en":"Portuguese"},{"css_classes":"western it","name":"Italiano","code":"it","name_en":"Italian"},{"css_classes":"western es","name":"Espa\\u00f1ol","code":"es","name_en":"Spanish"},{"css_classes":"western tr","name":"T\\u00fcrk\\u00e7e","code":"tr","name_en":"Turkish"},{"css_classes":null,"name":"English","code":"en","name_en":"English"},{"css_classes":"asian ko","name":"\\ud55c\\uad6d\\uc5b4","code":"ko","name_en":"Korean"},{"css_classes":"western fr","name":"fran\\u00e7ais","code":"fr","name_en":"French"},{"css_classes":"western ru","name":"\\u0420\\u0443\\u0441\\u0441\\u043a\\u0438\\u0439","code":"ru","name_en":"Russian"},{"css_classes":"western de","name":"Deutsch","code":"de","name_en":"German"},{"css_classes":"asian ja","name":"\\u65e5\\u672c\\u8a9e","code":"ja","name_en":"Japanese"}],"abBuckets":{"remember_me_on_signup_83":{"bucket":"experiment","version":9,"experiment_key":"remember_me_on_signup_83","bucket_names":["control","experiment"]},"Contact_Import_Images-40":{"bucket":"control","version":3,"experiment_key":"Contact_Import_Images-40","bucket_names":["control","images"]},"Contact_Import_Services-39":{"bucket":"control","version":4,"experiment_key":"Contact_Import_Services-39","bucket_names":["control","vertical","vertical_matched"]},"welcome_flow_addressbook_81":{"bucket":"control","version":8,"experiment_key":"welcome_flow_addressbook_81","bucket_names":["control","addressbook"]},"Relevance_V1-49":{"bucket":"control","version":10,"experiment_key":"Relevance_V1-49","bucket_names":["control","recent"]}},"pageLocaleClass":"western pt","pageLocale":"pt","globalConfig":{"photo_sizes":{"large":{"h":2048,"resize":"fit","w":1024},"medium":{"h":1200,"resize":"fit","w":600},"thumb":{"h":150,"resize":"crop","w":150},"small":{"h":480,"resize":"fit","w":340}},"non_username_paths":["about","account","accounts","activity","all","announcements","anywhere","api_rules","api_terms","apirules","apps","auth","badges","blog","business","buttons","contacts","devices","direct_messages","download","downloads","edit_announcements","faq","favorites","find_sources","find_users","followers","following","friend_request","friendrequest","friends","goodies","help","home","im_account","inbox","invitations","invite","jobs","list","login","logout","me","mentions","messages","newtwitter","notifications","nudge","oauth","phoenix_search","positions","privacy","public_timeline","related_tweets","replies","retweeted_of_mine","retweets","retweets_by_others","rules","saved_searches","search","sent","settings","share","signup","signin","similar_to","statistics","terms","tos","translate","trends","tweetbutton","twttr","update_discoverability","users","welcome","who_to_follow","widgets","zendesk_auth","media_signup","phoenix_qunit_tests"],"max_media_per_upload":1,"short_url_length_https":20,"characters_reserved_per_media":20,"photo_size_limit":3145728,"short_url_length":19},"requestCacheSeedData":[{"options":[{}],"json":{"profile_sidebar_border_color":"C0DEED","profile_background_tile":false,"profile_sidebar_fill_color":"DDEEF6","name":"Testando","created_at":"Fri Jul 01 11:10:49 +0000 2011","location":null,"profile_image_url":"http:\\/\\/a1.twimg.com\\/sticky\\/default_profile_images\\/default_profile_2_normal.png","is_translator":false,"profile_link_color":"0084B4","id_str":"327319701","follow_request_sent":false,"contributors_enabled":false,"favourites_count":0,"states":{"pending_email":"testandoXXXX@hotmail.com","bouncing_email":["testandoXXXX@hotmail.com"],"detached_email":false,"suspended":false,"needs_employee_email_update":false},"url":null,"default_profile":true,"id":327319701,"utc_offset":null,"profile_image_url_https":"https:\\/\\/si0.twimg.com\\/sticky\\/default_profile_images\\/default_profile_2_normal.png","profile_use_background_image":true,"listed_count":0,"lang":"pt","followers_count":0,"profile_text_color":"333333","protected":false,"profile_background_color":"C0DEED","profile_background_image_url_https":"https:\\/\\/si0.twimg.com\\/images\\/themes\\/theme1\\/bg.png","verified":false,"time_zone":null,"geo_enabled":false,"description":null,"notifications":false,"statuses_count":0,"default_profile_image":true,"friends_count":0,"profile_background_image_url":"http:\\/\\/a0.twimg.com\\/images\\/themes\\/theme1\\/bg.png","show_all_inline_media":false,"following":false,"screen_name":"tatXtxt"},"api_request_name":"account\\/verify_credentials"},{"options":[{"include_available_features":1,"include_entities":1,"pc":true,"contributor_details":true}],"json":[],"api_request_name":"statuses\\/home_timeline"},{"options":[{}],"json":{"sleep_time":{"end_time":null,"enabled":false,"start_time":null},"language":"pt","discoverable_by_email":true,"always_use_https":false,"geo_enabled":false},"api_request_name":"account\\/settings"},{"options":[{"pc":true}],"json":{"trends":{"current_trends":[{"name":"#listentoyourheart","url":"http:\\/\\/search.twitter.com\\/search?q=%23listentoyourheart"},{"name":"#youneedtositdown","url":"http:\\/\\/search.twitter.com\\/search?q=%23youneedtositdown"},{"name":"Teddy Bautista","url":"http:\\/\\/search.twitter.com\\/search?q=%22Teddy%20Bautista%22"},{"name":"#eqakl","url":"http:\\/\\/search.twitter.com\\/search?q=%23eqakl"},{"name":"Mayor Duterte","url":"http:\\/\\/search.twitter.com\\/search?q=%22Mayor%20Duterte%22"},{"name":"Brendon Urie","url":"http:\\/\\/search.twitter.com\\/search?q=%22Brendon%20Urie%22"},{"name":"Mirror Mirror","url":"http:\\/\\/search.twitter.com\\/search?q=%22Mirror%20Mirror%22"},{"name":"BTD","url":"http:\\/\\/search.twitter.com\\/search?q=BTD"},{"name":"'Perfect Night'","url":"http:\\/\\/search.twitter.com\\/search?q=%22'Perfect%20Night'%22"},{"name":"Black & White","url":"http:\\/\\/search.twitter.com\\/search?q=%22Black%20&%20White%22"}]}},"api_request_name":"trends\\/current"},{"options":[{}],"json":{"promo":{"name":"IOC Olympic Day (PT)","created_at":"Wed Jun 22 21:28:29 +0000 2011","promo_contents":"\\u003Ca href=\\"http:\\/\\/contest.olympic.org\\/\\" class=\\"definition\\" onClick=\\"javascript: pageTracker._trackPageview('\\/\\ndefinition\\/IOC_pt');\\"\\u003E\\u003Cstrong\\u003EDia Ol\\u00edmpico no Twitter\\u003C\\/strong\\u003E\\u003C\\/a\\u003E Comemore o espir\\u00edto dos Jogos Ol\\u00edmpicos no Twitter e voc\\u00ea poder\\u00e1 ganhar uma viagem a Londres 2012.","promo_type":"","updated_at":"Thu Jun 23 17:00:45 +0000 2011","id":150,"is_sponsored":false,"is_active":true,"locale":"pt"}},"api_request_name":"promos\\/random"}],"remoteIP":"189.104.75.181","appcacheRequiredMajorVersion":1,"userProperties":{"emailDiscoverabilitySet":true,"mobilePhoneDiscoverabilitySet":false,"deviceAddress":null,"discoverableByEmail":true,"discoverableByMobilePhone":false,"emailAddress":"null","deviceSetup":false},"currentUser":{"memberships_path":"\\/tatXtxt\\/lists\\/memberships","rgba_tweet_border_color":"rgba(0,132,180,0.15)","linkified_status":"","rgba_sidebar_color":"rgba(221,238,246,0.9)","user_followers_path":"\\/tatXtxt\\/followers","screen_name_from_server":"tatXtxt","profile_image_url_from_server":"http:\\/\\/a1.twimg.com\\/sticky\\/default_profile_images\\/default_profile_2_normal.png","rgba_newtweets_border_color":"rgba(0,132,180,0.25)","rgba_tweet_background_color":"rgba(0,132,180,0.1)","subscriptions_path":"\\/tatXtxt\\/lists\\/subscriptions","user_favorites_path":"\\/tatXtxt\\/favorites","profile_path":"\\/tatXtxt","id":327319701,"rgba_newtweets_background_color":"rgba(0,132,180,0.2)","lists_path":"\\/tatXtxt\\/lists","rgba_text_color":"rgba(51,51,51,0.6)","user_following_path":"\\/tatXtxt\\/following","latest_timestamp":"","account_profile_image_path":"\\/account\\/profile_image\\/tatXtxt","bigger_profile_image_url":"http:\\/\\/a1.twimg.com\\/sticky\\/default_profile_images\\/default_profile_2.png"},"requestFullCity":"br,05,feira_de_santana","postAuthenticityToken":"3de1b517590cad537393d7c2999d024524c8b492","isAdmin":false}
START;
答案 1 :(得分:1)
我使用\'将所有单引号转义并使用单引号将其封装起来,它似乎有效:
<?php
$json = '{"currentUserScreenName":"tatXtxt","recentPlaces":[],"cdnBase":{"versioned":{"ssl":["https:\/\/si0.twimg.com\/a\/1309465578"],"http":["http:\/\/a0.twimg.com\/a\/1309465578","http:\/\/a1.twimg.com\/a\/1309465578","http:\/\/a2.twimg.com\/a\/1309465578","http:\/\/a3.twimg.com\/a\/1309465578"]},"unversioned":{"ssl":["https:\/\/si0.twimg.com"],"http":["http:\/\/a0.twimg.com","http:\/\/a1.twimg.com","http:\/\/a2.twimg.com","http:\/\/a3.twimg.com"]}},"pageLocaleJS":"http:\/\/a3.twimg.com\/a\/1309465578\/javascripts\/phoenix\/i18n\/pt.js","becameUser":false,"payload":{"profiling":false,"conditionalTemplates":{}},"isNarrow":true,"deciderFeatures":{"tweet_stream_list":1,"geo_location":1,"people_stream_friends":1,"tweet_stream_favorites":1,"promo_component":1,"phoenix_local_gowalla":1,"new_trends_location_selector":1,"geo_ui":1,"flock":1,"phoenix_geo_v4":1,"geo_ui_dropdown_available":1,"tweet_stream_mentions_polling":1,"contact_import_stream":1,"html5Routing":1,"list_stream_memberships":1,"phoenix_frontpage_rotate_avatars":1,"tweet_stream_retweets_by_you":1,"inline_media_component":1,"whotofollow_random_sample":1,"phoenix_sandboxed_ajax":1,"tweet_stream_following_polling":1,"whotofollow_recommendations":1,"phoenix_first_time":1,"list_stream_own_lists":1,"phoenix_facets_logged_out":1,"phoenix_amazon_details":1,"in_reply_to_component":1,"sync_scribe":1,"geo_show_similar_places":1,"phoenix_turkey_permalink":1,"tweet_streams_polling":1,"media_flagging":1,"phoenix_search_relevance_logged_out":1,"user_shuffler":1,"mobile_download_gallery_logged_out":1,"phoenix_aol_video":1,"logged_out_people_search":1,"social_context":1,"email_device_settings":1,"people_streams":1,"tweet_stream_user_polling":1,"tweet_stream_retweets_by_you_polling":1,"people_stream_people_search":1,"phoenix_local_plancast":1,"scribe_client_event":1,"tweet_streams":1,"profile_combined_api":1,"tweet_stream_user":1,"phoenix_facets_videos":1,"phoenix_instagram_and_friends":1,"tweet_geo_component":1,"tweet_stream_mentions":1,"phoenix_tweetbox_talon":1,"phoenix_scribe":1,"phoenix_local_meetup":1,"tweet_stream_search":1,"phoenix_facets":1,"dashboard_activity_following":1,"retweeters_component":1,"people_stream_list_followers":1,"more_lists_component":1,"mt_tweet_backend_bing":1,"phoenix_talon_on_copy":1,"place_users_stream":1,"message_stream":1,"tweet_stream_home":1,"phoenix_autocomplete_place_trigger_words":1,"dashboard_activity_favorites":1,"dashboard_activity_listed":1,"list_streams":1,"tweet_stream_your_tweets_retweeted_polling":1,"phoenix_local_foursquare":1,"phoenix_puffin":1,"tweet_stream_list_polling":1,"tweet_stream_retweets_by_others":1,"phoenix_search_dropdown":1,"people_stream_follower_requests":1,"tweet_stream_home_polling":1,"trends_component":1,"phoenix_search_relevance":1,"tweet_stream_your_tweets_retweeted":1,"phoenix_pretty_links":1,"local_trends":1,"place_people_component":1,"people_stream_list_members":1,"place_tweets_component":1,"dashboard_activity_followers":1,"following_page_tweets_tab":1,"list_stream_subscriptions":1,"tweet_stream_retweets_by_others_polling":1,"mobile_download_gallery":1,"geo_more_places":1,"japanese_ad_component":1,"infinite_scroll":1,"tweet_stream_search_polling":1,"whotofollow_similarities":1,"people_stream_followers":1,"recent_tweets_component":1,"tweet_stream_favorites_polling":1,"welcome_warm_signup":1,"geo_allow_set_location_manually":1,"promptbird_phoenix":1,"phoenix_facets_images":1,"promoted_accounts_in_whotofollow_viewall":1,"suggestion_categories_streams":1,"geo_place_creation":1,"conversations":1,"tweet_stream_following":1,"phoenix_autocomplete":1,"onebox_user_search":1,"advanced_search":1,"i18n_new_translation_center":1,"fake_loggedout_decider":1,"newest_list_members_component":1},"adminRights":false,"isPreflight":false,"languages":[{"css_classes":"western pt","name":"Portugu\u00eas","code":"pt","name_en":"Portuguese"},{"css_classes":"western it","name":"Italiano","code":"it","name_en":"Italian"},{"css_classes":"western es","name":"Espa\u00f1ol","code":"es","name_en":"Spanish"},{"css_classes":"western tr","name":"T\u00fcrk\u00e7e","code":"tr","name_en":"Turkish"},{"css_classes":null,"name":"English","code":"en","name_en":"English"},{"css_classes":"asian ko","name":"\ud55c\uad6d\uc5b4","code":"ko","name_en":"Korean"},{"css_classes":"western fr","name":"fran\u00e7ais","code":"fr","name_en":"French"},{"css_classes":"western ru","name":"\u0420\u0443\u0441\u0441\u043a\u0438\u0439","code":"ru","name_en":"Russian"},{"css_classes":"western de","name":"Deutsch","code":"de","name_en":"German"},{"css_classes":"asian ja","name":"\u65e5\u672c\u8a9e","code":"ja","name_en":"Japanese"}],"abBuckets":{"remember_me_on_signup_83":{"bucket":"experiment","version":9,"experiment_key":"remember_me_on_signup_83","bucket_names":["control","experiment"]},"Contact_Import_Images-40":{"bucket":"control","version":3,"experiment_key":"Contact_Import_Images-40","bucket_names":["control","images"]},"Contact_Import_Services-39":{"bucket":"control","version":4,"experiment_key":"Contact_Import_Services-39","bucket_names":["control","vertical","vertical_matched"]},"welcome_flow_addressbook_81":{"bucket":"control","version":8,"experiment_key":"welcome_flow_addressbook_81","bucket_names":["control","addressbook"]},"Relevance_V1-49":{"bucket":"control","version":10,"experiment_key":"Relevance_V1-49","bucket_names":["control","recent"]}},"pageLocaleClass":"western pt","pageLocale":"pt","globalConfig":{"photo_sizes":{"large":{"h":2048,"resize":"fit","w":1024},"medium":{"h":1200,"resize":"fit","w":600},"thumb":{"h":150,"resize":"crop","w":150},"small":{"h":480,"resize":"fit","w":340}},"non_username_paths":["about","account","accounts","activity","all","announcements","anywhere","api_rules","api_terms","apirules","apps","auth","badges","blog","business","buttons","contacts","devices","direct_messages","download","downloads","edit_announcements","faq","favorites","find_sources","find_users","followers","following","friend_request","friendrequest","friends","goodies","help","home","im_account","inbox","invitations","invite","jobs","list","login","logout","me","mentions","messages","newtwitter","notifications","nudge","oauth","phoenix_search","positions","privacy","public_timeline","related_tweets","replies","retweeted_of_mine","retweets","retweets_by_others","rules","saved_searches","search","sent","settings","share","signup","signin","similar_to","statistics","terms","tos","translate","trends","tweetbutton","twttr","update_discoverability","users","welcome","who_to_follow","widgets","zendesk_auth","media_signup","phoenix_qunit_tests"],"max_media_per_upload":1,"short_url_length_https":20,"characters_reserved_per_media":20,"photo_size_limit":3145728,"short_url_length":19},"requestCacheSeedData":[{"options":[{}],"json":{"profile_sidebar_border_color":"C0DEED","profile_background_tile":false,"profile_sidebar_fill_color":"DDEEF6","name":"Testando","created_at":"Fri Jul 01 11:10:49 +0000 2011","location":null,"profile_image_url":"http:\/\/a1.twimg.com\/sticky\/default_profile_images\/default_profile_2_normal.png","is_translator":false,"profile_link_color":"0084B4","id_str":"327319701","follow_request_sent":false,"contributors_enabled":false,"favourites_count":0,"states":{"pending_email":"testandoXXXX@hotmail.com","bouncing_email":["testandoXXXX@hotmail.com"],"detached_email":false,"suspended":false,"needs_employee_email_update":false},"url":null,"default_profile":true,"id":327319701,"utc_offset":null,"profile_image_url_https":"https:\/\/si0.twimg.com\/sticky\/default_profile_images\/default_profile_2_normal.png","profile_use_background_image":true,"listed_count":0,"lang":"pt","followers_count":0,"profile_text_color":"333333","protected":false,"profile_background_color":"C0DEED","profile_background_image_url_https":"https:\/\/si0.twimg.com\/images\/themes\/theme1\/bg.png","verified":false,"time_zone":null,"geo_enabled":false,"description":null,"notifications":false,"statuses_count":0,"default_profile_image":true,"friends_count":0,"profile_background_image_url":"http:\/\/a0.twimg.com\/images\/themes\/theme1\/bg.png","show_all_inline_media":false,"following":false,"screen_name":"tatXtxt"},"api_request_name":"account\/verify_credentials"},{"options":[{"include_available_features":1,"include_entities":1,"pc":true,"contributor_details":true}],"json":[],"api_request_name":"statuses\/home_timeline"},{"options":[{}],"json":{"sleep_time":{"end_time":null,"enabled":false,"start_time":null},"language":"pt","discoverable_by_email":true,"always_use_https":false,"geo_enabled":false},"api_request_name":"account\/settings"},{"options":[{"pc":true}],"json":{"trends":{"current_trends":[{"name":"#listentoyourheart","url":"http:\/\/search.twitter.com\/search?q=%23listentoyourheart"},{"name":"#youneedtositdown","url":"http:\/\/search.twitter.com\/search?q=%23youneedtositdown"},{"name":"Teddy Bautista","url":"http:\/\/search.twitter.com\/search?q=%22Teddy%20Bautista%22"},{"name":"#eqakl","url":"http:\/\/search.twitter.com\/search?q=%23eqakl"},{"name":"Mayor Duterte","url":"http:\/\/search.twitter.com\/search?q=%22Mayor%20Duterte%22"},{"name":"Brendon Urie","url":"http:\/\/search.twitter.com\/search?q=%22Brendon%20Urie%22"},{"name":"Mirror Mirror","url":"http:\/\/search.twitter.com\/search?q=%22Mirror%20Mirror%22"},{"name":"BTD","url":"http:\/\/search.twitter.com\/search?q=BTD"},{"name":"\'Perfect Night\'","url":"http:\/\/search.twitter.com\/search?q=%22\'Perfect%20Night\'%22"},{"name":"Black & White","url":"http:\/\/search.twitter.com\/search?q=%22Black%20&%20White%22"}]}},"api_request_name":"trends\/current"},{"options":[{}],"json":{"promo":{"name":"IOC Olympic Day (PT)","created_at":"Wed Jun 22 21:28:29 +0000 2011","promo_contents":"\u003Ca href=\"http:\/\/contest.olympic.org\/\" class=\"definition\" onClick=\"javascript: pageTracker._trackPageview(\'\/\ndefinition\/IOC_pt\');\"\u003E\u003Cstrong\u003EDia Ol\u00edmpico no Twitter\u003C\/strong\u003E\u003C\/a\u003E Comemore o espir\u00edto dos Jogos Ol\u00edmpicos no Twitter e voc\u00ea poder\u00e1 ganhar uma viagem a Londres 2012.","promo_type":"","updated_at":"Thu Jun 23 17:00:45 +0000 2011","id":150,"is_sponsored":false,"is_active":true,"locale":"pt"}},"api_request_name":"promos\/random"}],"remoteIP":"189.104.75.181","appcacheRequiredMajorVersion":1,"userProperties":{"emailDiscoverabilitySet":true,"mobilePhoneDiscoverabilitySet":false,"deviceAddress":null,"discoverableByEmail":true,"discoverableByMobilePhone":false,"emailAddress":"null","deviceSetup":false},"currentUser":{"memberships_path":"\/tatXtxt\/lists\/memberships","rgba_tweet_border_color":"rgba(0,132,180,0.15)","linkified_status":"","rgba_sidebar_color":"rgba(221,238,246,0.9)","user_followers_path":"\/tatXtxt\/followers","screen_name_from_server":"tatXtxt","profile_image_url_from_server":"http:\/\/a1.twimg.com\/sticky\/default_profile_images\/default_profile_2_normal.png","rgba_newtweets_border_color":"rgba(0,132,180,0.25)","rgba_tweet_background_color":"rgba(0,132,180,0.1)","subscriptions_path":"\/tatXtxt\/lists\/subscriptions","user_favorites_path":"\/tatXtxt\/favorites","profile_path":"\/tatXtxt","id":327319701,"rgba_newtweets_background_color":"rgba(0,132,180,0.2)","lists_path":"\/tatXtxt\/lists","rgba_text_color":"rgba(51,51,51,0.6)","user_following_path":"\/tatXtxt\/following","latest_timestamp":"","account_profile_image_path":"\/account\/profile_image\/tatXtxt","bigger_profile_image_url":"http:\/\/a1.twimg.com\/sticky\/default_profile_images\/default_profile_2.png"},"requestFullCity":"br,05,feira_de_santana","postAuthenticityToken":"3de1b517590cad537393d7c2999d024524c8b492","isAdmin":false}';
print_r(json_decode($json));