How to print Json Files on Android page

Here is a program that might help you convert between the form you have now and the one I’m recommending. Save it to a file called bibleconv.js, and you can invoke it like so:

$ node bibleconv.js /path/to/existing/format.json > /path/to/new/format.json

let fs = require('fs');
fs.readFile(process.argv[2], 'utf8', (err, data) => {
  let inbound = JSON.parse(data);
  let outbound = inbound.map((book) => {
    let inchaps = book.chapters[0];
    let outchaps = [];
    for (let schapnum in inchaps) {
      let chapix = parseInt(schapnum) - 1;
      let verses = [];
      for (let sversenum in inchaps[schapnum]) {
        let vix = parseInt(sversenum) - 1;
        verses[vix] = inchaps[schapnum][sversenum];
      }
      outchaps[chapix] = verses;
    }
    book.chapters = outchaps;
    return book;
  });
  console.log(JSON.stringify(outbound));
});

I’m not 100% sure it will work out of the box, because I haven’t seen what the second chapter or book looks like, but it should be close enough for a starting point.

2 Likes