AS3中的关键值对

时间:2010-07-09 23:56:44

标签: php actionscript-3 json

我有一个后端PHP脚本将信息发送到as3应用程序。我发送的是Json信息,我做了什么使它成为一个键值对是在它前面粘贴一个键和一个等号,并将其发送出去。它适用于较小的值,但由于某种原因,它不适用于此,继承代码,我希望你们可以提供帮助。谢谢:))

c3po=[{"in_reply_to_status_id":null,"favorited":false,"contributors":null,"truncated":false,"source":"API<\/a>","created_at":"Fri Jul 09 23:15:29 +0000 2010","coordinates":null,"in_reply_to_screen_name":null,"in_reply_to_user_id":null,"user":{"profile_background_image_url":"http:\/\/a1.twimg.com\/profile_background_images\/100564626\/hexagons-twtr.jpg","description":"Graphic\/web designer and blogger founder of abduzeedo","location":"Porto Alegre","profile_sidebar_fill_color":"d9f0fd","profile_image_url":"http:\/\/a3.twimg.com\/profile_images\/555183361\/avatar-hair_normal.jpg","profile_background_tile":true,"statuses_count":7520,"profile_sidebar_border_color":"c4c4c4","screen_name":"abduzeedo","lang":"en","profile_use_background_image":true,"created_at":"Mon Dec 04 23:31:20 +0000 2006","followers_count":54252,"contributors_enabled":false,"friends_count":407,"geo_enabled":true,"profile_background_color":"000000","following":false,"favourites_count":114,"protected":false,"verified":false,"profile_text_color":"525252","name":"Fabio Sasso","time_zone":"Brasilia","url":"http:\/\/www.abduzeedo.com","id":41553,"notifications":false,"utc_offset":-10800,"profile_link_color":"2d68a9"},"place":null,"geo":null,"id":18154410176,"retweeted_status":{"in_reply_to_status_id":null,"favorited":false,"contributors":null,"truncated":false,"source":"feedly<\/a>","created_at":"Fri Jul 09 22:57:03 +0000 2010","coordinates":null,"in_reply_to_screen_name":null,"in_reply_to_user_id":null,"user":{"profile_background_image_url":"http:\/\/a3.twimg.com\/profile_background_images\/47193661\/curses_.png","description":"Degree in architecture and working with web.","location":"Porto Alegre, Brasil","profile_sidebar_fill_color":"bed3d4","profile_image_url":"http:\/\/a3.twimg.com\/profile_images\/554722981\/fabianome_normal.png","profile_background_tile":false,"statuses_count":2602,"profile_sidebar_border_color":"8cbdba","screen_name":"FabianoMe","lang":"en","profile_use_background_image":false,"created_at":"Thu Mar 27 21:07:04 +0000 2008","followers_count":1807,"contributors_enabled":false,"friends_count":191,"geo_enabled":true,"profile_background_color":"1a1107","following":true,"favourites_count":9,"protected":false,"verified":false,"profile_text_color":"25140d","name":"Fabiano Meneghetti","time_zone":"Brasilia","url":"http:\/\/fabiano.me","id":14238754,"notifications":false,"utc_offset":-10800,"profile_link_color":"d1242a"},"place":null,"geo":null,"id":18153403793,"text":"Beautiful Houses: Cliff House in Kerala, India http:\/\/bit.ly\/aAGjcb - via @GisMullr"},"text":"RT @FabianoMe: Beautiful Houses: Cliff House in Kerala, India http:\/\/bit.ly\/aAGjcb - via @GisMullr","percent":25}]

2 个答案:

答案 0 :(得分:1)

如果您正在使用JSON,那么您是否只能删除密钥而只返回JSON数据?这对我来说更有意义。

从您的actionscript代码中,您可以将URLLoader dataFormat属性的数据设置为URLLoaderDataFormat.TEXT,并将响应数据解析为JSON。

否则,如果你出于某种原因使用键/值方法,那么rawurlencode()可能会有所帮助:

$json_data = ''; // your current data goes here
echo 'c3po=' . rawurlencode($json_data);

答案 1 :(得分:0)

价值是否有换行符?这可能是一个问题,取决于您使用/读取键值的方式。也许如果您发布AS3应用程序中访问值的部分,我可以提供更多见解。