reyesoft / ngx-jsonapi

JSON API client library for Angular 5+ 👌 :: Production Ready 🚀
https://ngx-jsonapi.reyesoft.com/
MIT License
101 stars 52 forks source link

Is there a config option for variable naming conventions (snake, camel, dash)? #137

Closed petenys closed 5 years ago

petenys commented 5 years ago

My JSON API application is used now by an EmberJS app as well as native iOS and Android apps. All of the other applications seem to expect the object attributes to be dash-case at the API level, but they all use camelCase that gets converted automatically in each of the apps that consume the API.

The angular version here seems to always expect snake/underscore naming for all variables, but I don't know if there is a config that will allow me to continue to send and receive dash case as the other apps expect. I'm not sure if there is an config setting or an addon that will allow me to change the names on hydration and calls or if I'm going to have to add a new setting on the API to know that the calls are from the Angular app and to change the expecations there to always be snake case.

Any help would be extremely appreciated.

Thanks, Pete Nystrom pete@coachlogix.com

pablorsk commented 5 years ago

For now, you have only one option. Use objects like arrays. For example

books.attributes.coolName = 'Wow!';

to Snake

books.attributes['cool-name'] = 'Wow!';