0

I have a PHP file that is queried for information, and it passes a couple of variables back. One variable contains a JSON string with a variable in the object called message, which comes escaped to prevent it from causing issues if the message has an ampersand, single quote, etc in it.

&data={"message":"star%27s"}

Obviously the data sent is more complicated, this is just an example. After I take the data passed back by the PHP file and use URLVariables to decode it and access the "data" variable, it ends up looking like:

{"message":"star's"}

At this point I can't parse the JSON string, it will throw an error because of the single quote. Encoding it wouldn't work, it would encode more than just everything after the colon.

Is there a way to keep it from converting it? I was thinking I could manually parse the PHP returned string, but it seems unnecessary and I don't want risk running into issues later on because of it. I looked at the AS3 API and I couldn't find anything documenting this or how to disable it.

Any ideas or suggestions?

4

1 回答 1

0

你试试

Actionscript API escape() 和 unescape() 更多细节参见Escape 和 unescape

另请查看 JSON.parse 和 JSON.stringify working-with-native-json-in-flash-player-11

动作脚本中的 JSON 解码参见decode-json

于 2012-12-27T06:16:19.957 回答