• Recent
  • Tags
  • Unsolved
  • Solved
  • MagicMirror² Repository
  • Documentation
  • 3rd-Party-Modules
  • Donate
  • Discord
  • Register
  • Login
MagicMirror Forum
  • Recent
  • Tags
  • Unsolved
  • Solved
  • MagicMirror² Repository
  • Documentation
  • 3rd-Party-Modules
  • Donate
  • Discord
  • Register
  • Login
A New Chapter for MagicMirror: The Community Takes the Lead
Read the statement by Michael Teeuw here.

How do you convert xml to json (ideally without dependencies)

Scheduled Pinned Locked Moved Development
7 Posts 4 Posters 1.7k Views 4 Watching
Loading More Posts
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    AxLed Module Developer
    last edited by Feb 18, 2019, 11:26 AM

    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 in node_helper.js.
    How can i do this (ideally without dependencies)
    I have not found any way to use xml2json.js in node_helper.js so far.

    Looking forward to your replies.

    AxLED

    S 1 Reply Last reply Feb 18, 2019, 12:35 PM Reply Quote 0
    • S Offline
      sdetweil @AxLed
      last edited by Feb 18, 2019, 12:35 PM

      @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

      Sam

      How to add modules

      learning how to use browser developers window for css changes

      1 Reply Last reply Reply Quote 0
      • C Offline
        cowboysdude Module Developer
        last edited by Feb 18, 2019, 12:38 PM

        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.

        L 1 Reply Last reply Feb 18, 2019, 12:52 PM Reply Quote 0
        • L Offline
          lavolp3 Module Developer @cowboysdude
          last edited by Feb 18, 2019, 12:52 PM

          @cowboysdude Do we? Didn’t know about that. Why? Because it’s getting too complex?

          How to troubleshoot modules
          MMM-soccer v2, MMM-AVStock

          C 1 Reply Last reply Feb 18, 2019, 1:53 PM Reply Quote 0
          • C Offline
            cowboysdude Module Developer @lavolp3
            last edited by Feb 18, 2019, 1:53 PM

            @lavolp3 Well I use the principle that less moving parts tends to make things easier… :)

            L 1 Reply Last reply Feb 18, 2019, 2:20 PM Reply Quote 2
            • L Offline
              lavolp3 Module Developer @cowboysdude
              last edited by Feb 18, 2019, 2:20 PM

              @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…

              How to troubleshoot modules
              MMM-soccer v2, MMM-AVStock

              1 Reply Last reply Reply Quote 0
              • A Offline
                AxLed Module Developer
                last edited by Feb 18, 2019, 8:57 PM

                @sdetweil
                @cowboysdude
                @lavolp3

                Thanks for your posts, i got some further.

                1. 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 of MMM-Dreambox-xml2json.js inside of node_helper.js by calling parser.functionname() in my case parser.xml2json().

                AxLED

                1 Reply Last reply Reply Quote 0
                • 1 / 1
                1 / 1
                • First post
                  1/7
                  Last post
                Enjoying MagicMirror? Please consider a donation!
                MagicMirror created by Michael Teeuw.
                Forum managed by Sam, technical setup by Karsten.
                This forum is using NodeBB as its core | Contributors
                Contact | Privacy Policy