https://github.com/zzarcon/superagent-serializer
Superagent plugin to convert server payload into different cases
https://github.com/zzarcon/superagent-serializer
normalization normalize serialization serializer server-payload superagent superagent-plugin superagent-serializer
Last synced: 11 months ago
JSON representation
Superagent plugin to convert server payload into different cases
- Host: GitHub
- URL: https://github.com/zzarcon/superagent-serializer
- Owner: zzarcon
- License: mit
- Created: 2015-12-02T21:05:54.000Z (about 10 years ago)
- Default Branch: master
- Last Pushed: 2017-10-03T11:22:16.000Z (over 8 years ago)
- Last Synced: 2025-03-24T00:15:53.367Z (11 months ago)
- Topics: normalization, normalize, serialization, serializer, server-payload, superagent, superagent-plugin, superagent-serializer
- Language: JavaScript
- Homepage:
- Size: 5.86 KB
- Stars: 19
- Watchers: 3
- Forks: 2
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
[](https://badge.fury.io/js/superagent-serializer)
# superagent-serializer
> Superagent plugin to convert server payload into different cases
[superagent](https://github.com/visionmedia/superagent) plugin that brings you the hability of convert your server payload into different cases
# Installation
`$ npm i superagent-serializer --save`
# Usage
Having the following response
```json
{
"first_name": "Hector",
"last-name": "Zarco"
}
```
```javascript
var request = require('superagent');
var serializer = require('superagent-serializer');
serializer(request, 'camel');
request.get('data.json').send().end(function(err, res) {
console.log(res.firstName + ' ' + res.lastName);
});
```
This will convert the output into
```json
{
"firstName": "Zarco",
"lastName": "Hector Zarco"
}
```
# Cases
- **upper** : `foo_bar` -> `FOO BAR`
- **lower** : `fooBar` -> `foo bar`
- **snake** : `Foo bar!` -> `foo_bar`
- **pascal** : `foo.bar` -> `FooBar`
- **camel** : `foo, bar` -> `fooBar`
- **kebab** : `Foo? Bar.` -> `foo-bar`
- **constant** : `Foo-Bar` -> `FOO_BAR`
- **title** : `foo v. bar` -> `Foo v. Bar`
- **capital** : `foo_v_bar` -> `Foo V Bar`