javascript helper adding slashed to JSON object output

3 messages Options
Embed this post
Permalink
mlecho-2

javascript helper adding slashed to JSON object output

Reply Threaded More More options
Print post
Permalink

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 [hidden email]
To unsubscribe from this group, send email to [hidden email]
For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

mlecho-2

Re: javascript helper adding slashed to JSON object output

Reply Threaded More More options
Print post
Permalink

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

On Nov 7, 9:09 am, mlecho <[hidden email]> 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 [hidden email]
To unsubscribe from this group, send email to [hidden email]
For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

adaa

Re: javascript helper adding slashed to JSON object output

Reply Threaded More More options
Print post
Permalink
In reply to this post by mlecho-2

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 [hidden email]
To unsubscribe from this group, send email to [hidden email]
For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---