Read the statement by Michael Teeuw here.
How do you convert xml to json (ideally without dependencies)
-
I use xml2json.js to convert xml to json in my
module.js
.
For the further development of my module (MMM-Dreambox) I have to convert xml to json innode_helper.js
.
How can i do this (ideally without dependencies)
I have not found any way to use xml2json.js innode_helper.js
so far.Looking forward to your replies.
AxLED
-
@axled var xxx = require(‘xml2json’)
if u need something other than code YOU write, that is a dependency
create a package.json in your module folder and add those other things to the list to get installed after your module, with npm install
-
xml2js is the only way I know to do it. I know we try to not use dependencies but sometimes it can’t be helped.
-
@cowboysdude Do we? Didn’t know about that. Why? Because it’s getting too complex?
-
@lavolp3 Well I use the principle that less moving parts tends to make things easier… :)
-
@cowboysdude well you’re right in the aspect that one dependency of your rfacts module messed up the whole module for me.
Luckily it’s shining bright on my mirror now. And the facts are really good.
Now back to OT… -
@sdetweil
@cowboysdude
@lavolp3Thanks for your posts, i got some further.
- i added following line in my node_helper.js
const parser = require("./MMM-Dreambox-xml2json.js");
So node_helper.js checks for MMM-Dreambox-xml2json.js within the same directory.
After this, i can use a function ofMMM-Dreambox-xml2json.js
inside of node_helper.js by callingparser.functionname()
in my caseparser.xml2json()
.AxLED