json-restyle
Version:
Rename keys of JSON data
53 lines (39 loc) • 1.02 kB
Markdown
is a simple library to renames JSON data keys.
[ ](https://tapaswi.github.io)
|
[ ](https://stackblitz.com/github/tapaswi/json-restyle)
```bash
npm install json-restyle --save
```
```javascript
import { JsonRestyleModule } from 'json-restyle'
@NgModule({
...
imports: [
...
JsonRestyleModule
]
})
```
```javascript
import { JsonRestyleService } from 'json-restyle';
public constructor(private jsonService: JsonRestyleService) { }
/* Data to be modified */
let data = {
"version": "0.0.1",
"name": "json-restyle",
"description": "Reforms json object",
"feature": "json object key renaming"
};
/* "old key name" : "new key name" */
let jsonOptions = {
'version': 'ver',
'name': 'projName'
};
let modifiedJsonData = this.jsonService.reform(data, jsonOptions);
```
This