Question

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?

Was it helpful?

Solution

A \ character has special meaning in JSON. To represent one as data in JSON it must be expressed as an escape sequence: \\.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top