Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JSONAPIAdapter calls json.dumps with option ensure_ascii=True #70

Open
yudi-matsuzake opened this issue Oct 26, 2016 · 3 comments
Open

Comments

@yudi-matsuzake
Copy link

I'm implementing a RESTful server that reponses in the portuguese language and with the ensure_ascii=True the 'ã' looks like '\u00e3' in the json responses.

Is there any problem what will cause make this change (ensure_ascii=False)? Or is there any way to implement an option to JSONAPIAdapter call json.dumps with the argument ensure_ascii=False?

I think that decode the json to utf8 is not job for the client application.

Maybe can I use the postprocessors in some way?

@yudi-matsuzake yudi-matsuzake changed the title JSONAPIAdapter calls json.dumps the option ensure_ascii=True JSONAPIAdapter calls json.dumps with option ensure_ascii=True Oct 26, 2016
@timmartin19
Copy link
Member

Hm... you'd probably want to adapt the JSONAPIAdapter. What is your current output and what is the output that you actually desired? Can you give me an example?

@yudi-matsuzake
Copy link
Author

The current output:
{"data": {"relationships": {}, "attributes": [[{"id": 0, "species": "C\u00e3o"}, {"id": 1, "species": "Gato"}, {"id": 3, "species": "P\u00e1ssaro"}], {"links": {"previous": null, "next": null}}], "type": "species", "id": "", "links": {"self": "http://127.0.0.1:5000/catabicho.api/species"}}}

Desired output:
{"data": {"relationships": {}, "attributes": [[{"id": 0, "species": "Cão"}, {"id": 1, "species": "Gato"}, {"id": 3, "species": "Pássaro"}], {"links": {"previous": null, "next": null}}], "type": "species", "id": "", "links": {"self": "http://127.0.0.1:5000/catabicho.api/species"}}}

Basically the words "cão" and "pássaro" encoded with utf8.

Today a want to adapt the JSONAPIAdapter. Later I'll tell the results.

@yudi-matsuzake
Copy link
Author

I just put ensure_ascii=False in every json.dumps call and worked. Do you have any problem in mind that may appear when you add to JSONAPIAdapter? If you are interested I can make a pull request.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants