4

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.

1
  • just out of curiousity: this is an alternative driver to github.com/joymax/arango-python ? Did you check how it is done there? Commented Aug 29, 2013 at 5:11

1 Answer 1

3

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?

Sign up to request clarification or add additional context in comments.

1 Comment

The data was valid, I was mis using some pieces of the json library. This got me to look at my code again and see that, thanks!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.