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

Switching underscore for dashes #7

Open
gklinich opened this issue Aug 22, 2017 · 1 comment
Open

Switching underscore for dashes #7

gklinich opened this issue Aug 22, 2017 · 1 comment
Assignees

Comments

@gklinich
Copy link

I don't understand the the reason for the 'jsonify_attribute_name' and 'dejsonify_attribute_name' function.

For example in our API we have meta data like this:

'meta': {'sp_version': '8.3', 'api': 'SP', 'api_version': '3', 'sp_build_id': 'HHHH'}

when trying to retrieve the the 'sp_version' with 'resp.meta.sp_version', None is return because the 'sp_version' attributed is jsonify to 'sp-version'.

AFAIK our meta data is valid per the jsonapi spec

@tuomas2
Copy link
Contributor

tuomas2 commented Aug 23, 2017

It is common convention to use dashes and not underscores in JSON API schemas. Specification itself does not take a stand on it, but this conversion takes place because of this convention, to ease python access to data that follows this convention.

In general you can access entities that have underscore in their name with index operator (res['some_underscore']) but Meta seems to lack this operator. That is easy to implement so I did this in 8324c68.

Another option would be to make option to disable transformation alltogether to Session as an argument.

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

3 participants