-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsample.js
More file actions
81 lines (73 loc) · 2.13 KB
/
Copy pathsample.js
File metadata and controls
81 lines (73 loc) · 2.13 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
var unfolder = require('./unfolder');
var objects = [];
var sampleObject1 = {
name : {
first : 'Jon',
middle: 'Thomas',
last : 'Peterson'
},
age : 24,
education: {
school : {
location: {
country: 'Some',
city : 'Big'
},
type : 'state',
number : 4
},
university: {
location: {
country: 'Some',
city : 'Big'
},
type : 'state',
faculty : 'Math'
}
}
};
var sampleObject2 = {
name : {
first : 'Evans',
middle: 'Mighty',
last : 'Doorn'
},
age : 54,
education: {
school : {
location: {
country: 'Other',
city : 'Reil'
},
type : 'state',
number : 9
},
university: {
location: {
country: 'Some',
city : 'Fern'
},
type : 'state',
faculty : 'Physics'
}
}
};
var map = [{map: "First Name", property: 'name.first'},
{map: "Middle Name", property: 'name.middle'},
{map: "Last Name", property: 'name.last'},
{map: "Age", property: 'age'},
{map: "School County", property: 'education.school.location.country'},
{map: "School City", property: 'education.school.location.city'},
{map: "School Type", property: 'education.school.type'},
{map: "School Number", property: 'education.school.number'},
{map: "University County", property: 'education.university.location.country'},
{map: "University City", property: 'education.university.location.city'},
{map: "University Type", property: 'education.university.type'},
{map: "University Faculty", property: 'education.university.faculty'}];
objects.push(sampleObject1, sampleObject2);
unfolder.convertToLinearObjects(objects, map, function (err, result) {
console.dir(result);
});
unfolder.convertToLinearObjects(objects,null,function (err, result) {
console.dir(result);
});