--- /dev/null
+/**\r
+ * Copyright 2013 IBM Corp.\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ **/\r
+\r
+module.exports = function(RED) {\r
+ "use strict";\r
+ var js2xmlparser = require("js2xmlparser");\r
+\r
+ function Js2XmlNode(n) {\r
+ RED.nodes.createNode(this,n);\r
+ this.warn("This node has been deprecated and will be deleted in a future release. Please update your flow to use the 'xml' node.");\r
+ this.root = n.root;\r
+ var node = this;\r
+\r
+ this.on("input", function(msg) {\r
+ try {\r
+ var root = node.root || typeof msg.payload;\r
+ if (typeof msg.payload !== "object") { msg.payload = '"'+msg.payload+'"'; }\r
+ console.log(root, typeof msg.payload,msg.payload);\r
+ msg.payload = js2xmlparser(root, msg.payload);\r
+ node.send(msg);\r
+ }\r
+ catch(e) { console.log(e); }\r
+ });\r
+ }\r
+ RED.nodes.registerType("json2xml",Js2XmlNode);\r
+}\r