Skip to content

Commit b7e29c4

Browse files
Merge pull request #1 from pryomoax/publish-prep-reorg
Merging reorganization into master
2 parents e5dca44 + f45e98a commit b7e29c4

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

65 files changed

+13895
-3159
lines changed

.gitignore

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -147,5 +147,8 @@ Thumbs.db
147147
######################
148148
node_modules
149149

150-
# Test / Automation test results
151-
dist/test
150+
# Generared sources
151+
dev
152+
dist
153+
dts
154+
lib

.npmignore

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
build
2+
coverage
3+
docs
4+
examples
5+
src
6+
test
7+
wiki
8+
gulpfile.js
9+
tsconfig.json
10+
tslint.json
11+
.gitignore
12+
.prettierrc.yaml
13+
.publishrc
14+
.travis.yml
15+
.vscode

.prettierrc.yaml

Lines changed: 0 additions & 10 deletions
This file was deleted.

.vscode/launch.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,13 @@
77
{
88
"type": "node",
99
"request": "launch",
10-
"name": "Launch Main.js",
11-
"program": "${workspaceRoot}/dist/examples/test.js",
10+
"protocol": "inspector",
11+
"name": "Launch Test",
12+
"program": "${workspaceRoot}/dev/examples/test.js",
1213
"cwd": "${workspaceRoot}",
1314
"sourceMaps": true,
1415
"showAsyncStacks": true,
1516
"smartStep": false,
16-
"protocol": "inspector"
1717
},
1818
{
1919
"type": "node",
@@ -32,6 +32,6 @@
3232
"-t", "100000"
3333
],
3434
"internalConsoleOptions": "openOnSessionStart"
35-
}
35+
}
3636
]
3737
}

.vscode/tasks.json

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,14 @@
44
"version": "2.0.0",
55
"tasks": [
66
{
7-
"label": "json-decoder",
7+
"label": "build",
88
"type": "typescript",
99
"tsconfig": "tsconfig.json",
1010
"isBackground": true,
11-
"problemMatcher": "$tsc-watch",
11+
"problemMatcher": [
12+
"$tsc-watch"
13+
],
14+
"option": "watch",
1215
"presentation": {
1316
"echo": true,
1417
"reveal": "silent",

README.md

Lines changed: 19 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
# JSON Decoder
22

3-
![TypeScript Version](https://img.shields.io/badge/typescript-2.6.3-blue.svg)
3+
![TypeScript Version](https://img.shields.io/badge/typescript-2.8.3-blue.svg)
44
![Code Style](https://img.shields.io/badge/codestyle-TypeScript-green.svg)
5-
![](https://img.shields.io/badge/node-8.9.3-green.svg)
5+
![](https://img.shields.io/badge/node-8.11.1-green.svg)
66
[![GitHub license](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/pryomoax/json-decoder/master/LICENSE)
77

88
`json-decoder` allows TypeScript and JavaScript projects to adorn class declarations with JSON decoding decorators to support automatic decoding and marshalling of JSON objects to full prototype objects.
@@ -13,15 +13,7 @@
1313

1414
| Version | Description |
1515
| :-----: | ---------------------------------------- |
16-
| 0.1.x | In Progress |
17-
18-
## Distributions
19-
20-
This module is written using [TypeScript](http://typescriptlang.org) and distributed with the following JavaScript support:
21-
22-
- [`json-decoder/dist`](./master/node/dist)
23-
24-
A TypeScript compiler is not required to consume this module
16+
| 0.4.x | In Progress |
2517

2618
## Usage
2719

@@ -62,7 +54,7 @@ Prototype properties can be decorated with `@jsonProperty`, inheriting the proto
6254
> // Mapped 'id' property
6355
> @jsonProperty
6456
> public readonly id: number
65-
>
57+
>
6658
> // Mapped 'name' property
6759
> @jsonProperty
6860
> public readonly name: string
@@ -74,7 +66,7 @@ To decode an `Account` class, use `JsonDecoder.decode` with a JSON object (or J
7466
> ```Javascript
7567
> import { JsonDecoder } from 'json-decoder'
7668
> import { Account } from './account'
77-
>
69+
>
7870
> const json = {
7971
> id: 1001,
8072
> name: 'John Smith',
@@ -99,7 +91,7 @@ The following uses the decorator describing the JSON property `accountId` mapped
9991
> // Alias 'id' to 'accountId' property
10092
> @jsonAliasProperty('accountId')
10193
> public readonly id: number
102-
>
94+
>
10395
> // ...
10496
> }
10597
> ```
@@ -109,7 +101,7 @@ Note the JSON object below is using `accountId` instead of `id`
109101
> ```Javascript
110102
> import { JsonDecoder } from 'json-decoder'
111103
> import { Account } from './account'
112-
>
104+
>
113105
> const json = {
114106
> accountId: 1001,
115107
> name: 'John Smith',
@@ -148,7 +140,7 @@ The of interest `name` properties can be flatten
148140
>
149141
> @jsonAliasProperty('name.fullName')
150142
> public readonly fullName: string
151-
>
143+
>
152144
> // ...
153145
> }
154146
> ```
@@ -175,26 +167,26 @@ The decode could map index `0` of `profiles` by using `profiles@0`. At the same
175167
> @jsonDecodable()
176168
> class Account {
177169
> // ...
178-
>
170+
>
179171
> @jsonAliasProperty('profiles@0')
180172
> public readonly primaryProfile: number
181-
>
173+
>
182174
> @jsonProperty
183175
> public readonly profiles: Array<number>
184-
>
176+
>
185177
> // ...
186178
> }
187179
> ```
188180
189181
Key paths can be a long as the JSON supports. `property.arr@0.anotherProperty.YAP` will attempt to look up `YAP`, the end value. If at any point any sub-property returns `undefined` then `undefined` will be returned. If `null` is returned for any but the last property then `undefined` will be returned, else `null` will be returned.
190182
191-
`@` and `.` are synonmous with one another (subject to change) but provide a more readable structure of intent. That is '.' sub-property, '@' index. `a.b.c` is the same as `a@b@c`.
183+
`@` and `.` are synonmous with one another (subject to change) but provide a more readable structure of intent. That is '.' sub-property, '@' index. `a.b.c` is the same as `a@b@c`.
192184
193185
### Root Indexing
194186
195187
As a convenience, you may use `@index` as an alias, which will attempt to map a source JSON object that is an array, at `index` to the class prototype property.
196188
197-
Using an example of a message protocol from a network request, the message is composed of a `[header, body]` structure.
189+
Using an example of a message protocol from a network request, the message is composed of a `[header, body]` structure.
198190
199191
> ```Javascript
200192
> [
@@ -211,10 +203,10 @@ Decoding the above message use `@jsonAliasProperty('@1.name')`, where `@1` repre
211203
> @jsonDecodable()
212204
> class AccountMessage {
213205
> // ...
214-
>
206+
>
215207
> @jsonAliasProperty('@1.name')
216208
> public readonly name: string
217-
>
209+
>
218210
> // ...
219211
> }
220212
> ```
@@ -267,15 +259,15 @@ To marshal `profiles` into an `Array` of `Number`
267259
> @jsonDecodable()
268260
> class Account {
269261
> // ...
270-
>
262+
>
271263
> @jsonAliasProperty('profiles', [Number])
272264
> public readonly profiles: Array<number>
273-
>
265+
>
274266
> // ...
275267
> }
276268
> ```
277269
278-
Array marshalling can also convert a single property value into an array. If the JSON object only had a single scalar property value instead, it will creating an `Array` of one element.
270+
Array marshalling can also convert a single property value into an array. If the JSON object only had a single scalar property value instead, it will creating an `Array` of one element.
279271
280272
All element marshaling still apply here too
281273
@@ -303,7 +295,7 @@ Finally, with marshaling arrays, a JSON property with an array can be marshalled
303295
> public readonly primaryProfile: number
304296
>
305297
> // ...
306-
>
298+
>
307299
> @jsonAliasProperty('profiles', [Number])
308300
> public readonly profiles: Array<number>
309301
> ```

dist/examples/alias-properties.js

Lines changed: 0 additions & 132 deletions
This file was deleted.

dist/examples/alias-properties.js.map

Lines changed: 0 additions & 1 deletion
This file was deleted.

0 commit comments

Comments
 (0)