-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtoxml.js
More file actions
88 lines (81 loc) · 1.57 KB
/
toxml.js
File metadata and controls
88 lines (81 loc) · 1.57 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
81
82
83
84
85
86
87
88
module.exports = {
name: "toxml",
ns: "json",
title: "JSON To XML",
description: "Converts JSON to Simple XML",
phrases: {
active: "Parsing JSON string"
},
ports: {
input: {
json: {
type: "object",
title: "JSON",
required: true
},
root: {
type: "string",
title: "Root Element",
"default": ""
},
header: {
type: "boolean",
title: "Add Header?",
"default": true
}
},
output: {
out: {
type: "object",
title: "The Javascript Object"
},
error: {
type: "object",
title: "Error"
}
}
},
dependencies: {
npm: {
json2xml: require('json2xml')
}
},
fn: function toxml(input, $, output, state, done, cb, on, json2xml) {
var r = function() {
var obj = {};
if ($.root) {
obj[$.root] = $.json;
} else {
obj = $.json;
}
output.out = $.create(json2xml(obj, {
header: $.header
}));
/*
on.input.root = function() {
state.root = $.root;
};
on.input.header = function() {
state.header = $.header;
};
on.input.json = function() {
var obj = {};
if(state.root) {
obj[state.root] = $.json;
} else {
obj = $.json;
}
output({
out: json2xml($.json, { header: state.header })
});
};
*/
}.call(this);
return {
output: output,
state: state,
on: on,
return: r
};
}
}