Can anyone explain this PHP code using json_encode and json_decode?

json, php

Solution

Because it's part of the JSON standard

http://json.org/

char

any-Unicode-character-
    except-"-or-\-or-
    control-character
\"
\\
\/ <---- see here?
\b
\f
\n
\r
\t
\u four-hex-digits

Problem

``` $a = '{ "tag": "<b></b>" }'; echo json_encode( json_decode($a) ); ``` This outputs: ``` {"tag":"<b><\/b>"} ``` when you would think it would output exactly the input. For some reason json_encode adds an extra slash.

Original source