ColtonProvias / sqlalchemy-jsonapi

JSONAPI implementation for use with SQLAlchemy
MIT License
70 stars 27 forks source link

Library converts underscores to hyphens against spec #24

Open jimbobhickville opened 8 years ago

jimbobhickville commented 8 years ago

The spec allows for member names with underscores, but this library converts them to hyphens. I'd prefer that it at least be configurable to not do that, since it makes it annoying to pull the data out in Javascript:

data.attributes.some_field vs data.attributes['some-field']

http://jsonapi.org/format/#document-member-names-allowed-characters

ColtonProvias commented 8 years ago

I personally prefer underscores over dasherized. However, some of the community around JSON API (especially Ember Data) has taken to using hyphens instead of underscores. As the majority of the users of this project use Ember Data, I went with hyphens just to ease setup.

Since 5.0.0 is the next major release and as it is a breaking release, I'll let it be more freeform on attribute names and such.

ColtonProvias commented 8 years ago

Actually, looking into it further, the use of hyphens is actually recommended.

http://jsonapi.org/recommendations/#naming

I'll make it overridable in the next version with default being hyphens.

jimbobhickville commented 8 years ago

Ah, I didn't see that. I can put up a PR to let you override the default behavior if that's cool with you. I have a fork where I just took out dasherize entirely because it was causing me a lot of pain (I'm not using Ember). I can fix it to make it configurable.