Question

I am currently working on a python3.3 api for arangodb and am running into the following problem in the HTTP responses when requesting things from arango's RESTful api.

the specific example has to do with the sha256 hashes of password. if a section of the hashed password was this:

w/JjMM0gNl

when I use any of the python http libs the response is formated as such:

w\\/JjMM0gNl

encoding/decoding with various methods does not solve this and I am wondering what I can do to remedy this problem. If you are not familiar with arango, data is returned as json.

Was it helpful?

Solution

The reason might be that forward slashes are allowed to be escaped in JSON.

The forward slashes in the following JSON might actually be escaped with a backslash.

Unescaped:

{"foo/bar":"bar/baz"}

Escaped:

{"foo\/bar":"bar\/baz"}

When retrieving such escaped data back, the decoder needs to handle the \ in front of the / and ignore them. I think most decoders do not care whether or not forward slashes are escaped, at least they parse JSON data happily with forward slashes being escaped and without.

In any case, when you retrieve your data back as a python object from the decoder, the escape characters should go away. Handling escape sequences is a task encoders/decoders should handle transparently for you.

To go on: can you veryify if the JSON response from the server is actually correct? If yes, can you then try with a standalone python program whether your decode handles encoding/decoding of such string correctly?

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