• 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.

Use a local JSON file with MMM-JsonTable Module

Scheduled Pinned Locked Moved Solved Troubleshooting
8 Posts 4 Posters 3.5k 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.
  • R Offline
    REB
    last edited by Sep 4, 2018, 7:36 AM

    @Mykle1
    Thanks for the reply. I had tried that url plus others. I even put the file in a folder within the module folder named ‘public’ but that didn’t work either.

    I don’t think the module supports local json files - how do I determine this?

    I think I’ll try to develop my own module - it’ll be a good learning experience if nothing else.

    Thanks again.

    ? 1 Reply Last reply Sep 4, 2018, 7:50 AM Reply Quote 0
    • ? Offline
      A Former User @REB
      last edited by Sep 4, 2018, 7:50 AM

      @reb
      You can check Which url is derived from you config.js by this;
      node_helper.js, in line 11

      ...
      getJson: function (url) {
        var self = this;
        console.log(url)  // add this.
        request({ url: url, method: 'GET' }, function (error, response, body) {
      ...
      
      1 Reply Last reply Reply Quote 0
      • R Offline
        REB
        last edited by Sep 4, 2018, 10:55 AM

        OK, I have solved the issue - the json file causes this error:

        |mm     | Whoops! There was an uncaught exception...
        0|mm     | SyntaxError: Unexpected token  in JSON at position 0
        0|mm     |     at JSON.parse (<anonymous>)
        0|mm     |     at Request._callback (/home/pi/MagicMirror/modules/MMM-JsonTable/node_helper.js:15:21)
        0|mm     |     at Request.self.callback (/home/pi/MagicMirror/node_modules/request/request.js:186:22)
        0|mm     |     at emitTwo (events.js:126:13)
        0|mm     |     at Request.emit (events.js:214:7)
        0|mm     |     at Request.<anonymous> (/home/pi/MagicMirror/node_modules/request/request.js:1163:10)
        0|mm     |     at emitOne (events.js:116:13)
        0|mm     |     at Request.emit (events.js:211:7)
        0|mm     |     at IncomingMessage.<anonymous> (/home/pi/MagicMirror/node_modules/request/request.js:1085:12)
        0|mm     |     at Object.onceWrapper (events.js:313:30)
        0|mm     | MagicMirror will not quit, but it might be a good idea to check why this happened. Maybe no internet connection?
        0|mm     | If you think this really is an issue, please open an issue on GitHub: https://github.com/MichMich/MagicMirror/issues
        

        There are three bytes at the beginning of the json file before the first ‘{’. I am using an Excel to JSON converter from where I copy and paste the data.

        I use VS Code as my code editor and with a blank new file, when I paste the data from the online converter and save, those extra bytes are at the start of the file. Same with Notepad and Editplus.

        Without these 3 extra bytes, the module loads the file OK. Now I just need to figure out how to save the data without those extra bytes.

        BTW, the correct url that I used is:

         'http://192.168.1.27:8080/modules/MMM-JsonTable/xxxxxx.json'
        
        1 Reply Last reply Reply Quote 1
        • R Offline
          REB
          last edited by Sep 4, 2018, 1:17 PM

          OK, I’ve gotten to the bottom of the 3 extra bytes at the beginning of my json file - they are the utf-8 BOM (EF BB BF).

          Fortunately, I have a script (on a Directory Opus button) that will remove these bytes (or put them back if need be).

          Thanks to those that offered advice etc.

          S 1 Reply Last reply Sep 4, 2018, 4:40 PM Reply Quote 1
          • S Offline
            sdetweil @REB
            last edited by sdetweil Sep 7, 2018, 11:32 AM Sep 4, 2018, 4:40 PM

            @reb those characters are called the BOM (Byte Order Mark)… added by advanced word processing editors…

            u can use Notepad++ to remove them too…

            u need to change editors to make sure you don’t add them back accidentally…

            Sam

            How to add modules

            learning how to use browser developers window for css changes

            R 1 Reply Last reply Sep 5, 2018, 8:08 AM Reply Quote 0
            • R Offline
              REB @sdetweil
              last edited by Sep 5, 2018, 8:08 AM

              @sdetweil said in Use a local JSON file with MMM-JsonTable Module:

              @reb those characters are called the BOM (Bill of Material)… added by advanced word processing editors…

              u can use Notepad++ to remove them too…

              u need to change editors to make sure you don’t add them back accidentally…

              @sdetweil
              Thanks for the info about removing the BOM (Byte Order Mark). I use an Explorer replacement program called Directory Opus which is awesome and one of the developers wrote a script that can be attached to a toolbar button that can add, remove or toggle the Byte Order Mark.

              1 Reply Last reply Reply Quote 0
              • 1 / 1
              1 / 1
              • First post
                7/8
                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