Pregunta

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?

¿Fue útil?

Solución

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

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top