javascript helper adding slashed to JSON object output

View: New views
3 Messages — Rating Filter:   Alert me  

javascript helper adding slashed to JSON object output

by mlecho-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


hi, i am using the javascript helper to generate JSON feeds. It works
great, except for one thing...if a json property has  a value that is
an absolute url, cakephp wants to escape all the slashes...exampe:

{"flag_img":"http:\/\/www.website.com\/themes\/images\/country\/
countryimage.png"}

how can i get that url without escapes? I just need it as a straight
string.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To post to this group, send email to cake-php@...
To unsubscribe from this group, send email to cake-php+unsubscribe@...
For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---


Re: javascript helper adding slashed to JSON object output

by mlecho-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


ah- echo stripslashes($javascript->object($data));
seems to do the trick
unless there is a better way?

On Nov 7, 9:09 am, mlecho <saltlessbr...@...> wrote:
> hi, i am using the javascript helper to generate JSON feeds. It works
> great, except for one thing...if a json property has  a value that is
> an absolute url, cakephp wants to escape all the slashes...exampe:
>
> {"flag_img":"http:\/\/www.website.com\/themes\/images\/country\/
> countryimage.png"}
>
> how can i get that url without escapes? I just need it as a straight
> string.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To post to this group, send email to cake-php@...
To unsubscribe from this group, send email to cake-php+unsubscribe@...
For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---


Re: javascript helper adding slashed to JSON object output

by ABCoder :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


this is how JSON works. You need to unescape() the string in the
javascript before using it. if you use jQuery it's automatically done.
If you unescape it from php you'll be in trouble from some browsers.

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To post to this group, send email to cake-php@...
To unsubscribe from this group, send email to cake-php+unsubscribe@...
For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---