sqlalchemy-jsonapi icon indicating copy to clipboard operation
sqlalchemy-jsonapi copied to clipboard

Library converts underscores to hyphens against spec

Open jimbobhickville opened this issue 9 years ago • 3 comments

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

jimbobhickville avatar Aug 20 '16 22:08 jimbobhickville

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 avatar Aug 23 '16 18:08 ColtonProvias

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.

ColtonProvias avatar Aug 23 '16 19:08 ColtonProvias

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.

jimbobhickville avatar Aug 23 '16 20:08 jimbobhickville