A \
character has special meaning in JSON. To represent one as data in JSON it must be expressed as an escape sequence: \\
.
Weird JSON output for filepaths
题
I'm using JSON::XS, and I'm getting some weird output from an encoding of some file paths.
To create the output, I just call encode_json
on some data that I get from calling a dir command from perl (using ``
). Which I save in an array.
I end up with a JSON string that looks like the following:
"\"E: \\\\helm\\\\Layman1\\n\""
Where are the extra backslashes coming from?
解决方案
不隶属于 StackOverflow