-2

I entered urls into a MySQL db and when I log it out as json /php I get this:

http:\/\/www.etc....

How can I fix this?

Brad
  • 159,648
  • 54
  • 349
  • 530
marciokoko
  • 4,988
  • 8
  • 51
  • 91

2 Answers2

4

JSON escapes / as \/ - this is because older browser JavaScript need to use eval to parse it, and many old browsers would use </ to mark the end of a JavaScript block. Therefore, \/ makes it safe.

Niet the Dark Absol
  • 320,036
  • 81
  • 464
  • 592
  • Thanks. How do I fix it so I can get the no-forward-slashes version? How do I parse it? – marciokoko Jul 08 '13 at 14:57
  • You would need to pass `JSON_UNESCAPED_SLASHES` as the second argument to `json_encode`. Note that it shouldn't matter, really, since if you're using `json_encode` then the decoding context will remove the backslashes anyway. – Niet the Dark Absol Jul 08 '13 at 16:50
2

This has nothing to do with MySQL, but is the JSON-encoding of your slashes.

See also: JSON: why are forward slashes escaped?

Community
  • 1
  • 1
Brad
  • 159,648
  • 54
  • 349
  • 530