1 Reply Latest reply on Jul 26, 2010 1:24 PM by JohanVelthuis

    JSON encoding problem with entities

    Handycam Level 1

      I am trying to pass actionscript strings that have entities such as the Degrees symbol (as in 175°, not sure if the degree symbol shows here)

       

      I have a string like:

      private var step7b:String = "Cool the custard to below 70° F by stirring it over the ice bath. ";

       

      When the PHP attempts to write out this line of text it either fails completely, or prints the wrong entity code. such as "Preheat oven to 325% u02DAF"

       

      What do I need to do to correctly pass symbols such as the degree sign from an Actionscript string to PHP?

       

      Note: Entities loaded from XML work fine.  It's only AS string variables.  And this whole setup worked correctly when I used to use a WSDL service, the JSON is new and it's when this problem arose.  I am using this code block:

       

      
      // create the JSON
                          var objSend:Object = new Object();
                          var dataString:String = JSON.encode(packagedData);
                          dataString = escape(dataString);
                          objSend.jsonSendData = dataString;
      
      
      
      

        • 1. Re: JSON encoding problem with entities
          JohanVelthuis

          Hi,

           

          You are using something like dataString = escape(jsonString);

           

          the escape function in actionscripts does about the same as urlencode(addslashes(jsongString) in php.

           

          So you could try what happens if you leave out the escape or if you're able to adjust the php side, then

          use a urldecode(jsonString) or something.