Skip to content

Commit 2f36265

Browse files
authored
Markdown syntax highlighting
1 parent c99c41d commit 2f36265

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

README.md

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,11 @@ A Node package for transforming(mapping) one JSON object to another based on a s
88
npm install json_transform --save
99

1010
## Usage
11-
11+
```javascript
1212
var JSONTransform = require('json_transform');
13-
13+
```
1414
#### Input
15+
```javascript
1516
var input = {
1617
"id": 101,
1718
"content": "My first npm package",
@@ -80,6 +81,7 @@ A Node package for transforming(mapping) one JSON object to another based on a s
8081
]
8182
}
8283
};
84+
```
8385

8486
#### Template
8587
A template specifies how the input json should be transformed to the desired output json. The key value pair in template json specifies the input key to desired key name transformation(can be same if key need not be renamed). In case of nested json object/array, the desired key name is specified explicitly and the desired data specifies the template to be used for transforming inner object. The input keys not specified in the template are filtered out in the output json.
@@ -91,7 +93,7 @@ A template specifies how the input json should be transformed to the desired out
9193
**Example:** In the sample below, `id` key from input transforms to `user_id` key in output json. `content` and `latitude` key need not be renamed so they are defined in `includeTheseKeys` array.
9294

9395
For the nested `user` object, the desired key is `userDetails`, so in the output, the data(specified by template `desiredData`) for `user` object comes under the key `userDetails`. The `longitude` key is not specified in template, so it is omitted from the ouput json.
94-
96+
```javascript
9597
var template = {
9698
"id": "user_id",
9799
"includeTheseKeys": [
@@ -135,9 +137,9 @@ For the nested `user` object, the desired key is `userDetails`, so in the output
135137
}
136138
}
137139
};
138-
140+
```
139141
#### Output
140-
142+
```javascript
141143
var output = JSONTransform.transform(input, template);
142144
------------------------------------------------------
143145
{
@@ -202,12 +204,12 @@ For the nested `user` object, the desired key is `userDetails`, so in the output
202204
}
203205
}
204206
}
205-
207+
```
206208
## Release History
207209

208210
* **0.1.0** Initial release
209211
* **0.1.1** Fixed blank values in array
210212
* **0.1.2** Bug fix for array exceeding bounds
211213
* **0.1.3** Handling for undefined keys in JSON
212214
* **0.1.4** Added functionality to define all keys to be included in output json, in an array instead of mapping one to one
213-
* **0.1.5** Added support for mapping nested json keys
215+
* **0.1.5** Added support for mapping nested json keys

0 commit comments

Comments
 (0)