8000 Clean-up. · hubcarl/json-typescript-mapper@8f0afb8 · GitHub
[go: up one dir, main page]

Skip to content

Commit 8f0afb8

Browse files
Mönnich Daniel, ENT-BD-PDDMönnich Daniel, ENT-BD-PDD
Mönnich Daniel, ENT-BD-PDD
authored and
Mönnich Daniel, ENT-BD-PDD
committed
Clean-up.
1 parent 389fa56 commit 8f0afb8

File tree

4 files changed

+1
-101
lines changed

4 files changed

+1
-101
lines changed

index.js

Lines changed: 0 additions & 12 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

index.ts

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ export interface IDecoratorMetaData<T> {
2424
clazz?: {new(): T},
2525
customConverter?: ICustomConverter,
2626
excludeToJson?: boolean
27-
// noConversion?: boolean
2827
}
2928

3029
/**
@@ -178,23 +177,12 @@ export function deserialize<T>(Clazz: {new(): T}, json: Object): T {
178177
return instance;
179178
}
180179

181-
//TODO only recursive if clazz is given in metadata
182-
//TODO also for arrays
183-
//TODO and probably remove unnecessary noConversion option
184180
export function serialize(instance: any): any {
185181

186182
if (!isTargetType(instance, 'object') || isArrayOrArrayClass(instance)) {
187183
return instance;
188184
}
189185

190-
// if (isPrimitiveOrPrimitiveClass(instance)) {
191-
// return instance;
192-
// }
193-
194-
// if (isArrayOrArrayClass(instance)) {
195-
// return instance.map(instanceArr => serialize(instanceArr));
196-
// }
197-
198186
const obj = {};
199187
Object.keys(instance).forEach(key => {
200188
const metadata = getJsonProperty(instance, key);
@@ -221,9 +209,5 @@ function serializeProperty(metadata: IDecoratorMetaData<any>, prop: any): any {
221209
return prop.map(propItem => serialize(propItem));
222210
}
223211

224-
// if (!isPrimitiveOrPrimitiveClass(prop)) {
225212
return serialize(prop);
226-
// }
227-
228-
// return prop;
229213
}

spec/custom-converter.js

Lines changed: 0 additions & 33 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

spec/custom-converter.ts

Lines changed: 1 addition & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,46 +1,7 @@
11
import {expect} from 'chai';
2-
import {deserialize, serialize, JsonProperty, ICustomConverter} from '../index';
2+
import {serialize, JsonProperty} from '../index';
33
import dateConverter from './common/dateconverter';
44

5-
6-
// const dateConverter: ICustomConverter = {
7-
// fromJson(data: any): any {
8-
// return new Date(data);
9-
// },
10-
//
11-
// toJson(data: any): any {
12-
// return 'some-date';
13-
// }
14-
// };
15-
16-
// class Student {
17-
//
18-
// @JsonProperty('Name')
19-
// name: string = undefined;
20-
//
21-
// @JsonProperty({customConverter: dateConverter})
22-
// dateOfBirth: Date = undefined;
23-
//
24-
// constructor() {}
25-
// }
26-
27-
28-
//TODO put in main test file where deserialization is tested
29-
// describe('custom-converter', function () {
30-
//
31-
// it('should use the custom converter if available for deserialization', function () {
32-
// const json = {
33-
// "Name": "Mark",
34-
// dateOfBirth: "1995-11-10"
35-
// };
36-
// const student = deserialize(Student, json);
37-
// expect(student.name).to.be.equals('Mark');
38-
// expect(student.dateOfBirth).to.be.instanceof(Date);
39-
// });
40-
//
41-
// });
42-
43-
445
describe('serialize', function () {
456

467
it('should use the property name given in the meta data', function () {

0 commit comments

Comments
 (0)
0