thetallweeks
6/8/2018 - 11:34 PM

OSIS-to-JSON.js

var response = {
  title: 'Genesis 1:2-3', // what is x-gen?
  verses: [
    { // first verse (we'll loop through if there are many)
      osisID: 'Gen.1.2',
      words: [
        { // words not within <w> are converted to this
          $: 'The' // $ is always a string value
        },
        {
          lemma: 'strong:G5613 lemma.TR:ως',
          morph: 'robinson:ADV',
          src: '1',
          $: 'earth'
        },
        {
          $: 'was',
          lemma: 'strong:H01961',
        },
        {
          tag: 'note', // we can use "tag" for any special visual formatting (superscript for instance)
          noteType: 'crossReference',
          osisID: 'Gen.1.2!crossReference.b',
          osisRef: 'Gen.1.2',
          $: 'b', // from n="b"
          refs: [
            {
              osisRef: 'Jer.4.23'
              $: 'Jer. 4:23'
            }
          ] 
        },
        {
          $: 'without form',
          lemma: 'strong:H08414'
        },
        {
          $: 'and'
        },
        ...
        {
          tag: 'q',
          sId: '01001003.1',
          $: '“'
        },
        {
          $: 'Let there'
        },
        ...
        {
          tag: 'q', // for quote. Does this need to be separate?
          eId: '01001003.1',
          $: '”'
        }
      ]
    },
    ... // more objects for additional verses
  ]
};
<div>
 <title type="x-gen">Genesis 1:2-3</title>
 <verse osisID="Gen.1.2">
 The
 <w lemma="strong:H0776">earth</w>
 <w lemma="strong:H01961">was</w>
 <note n="b" osisID="Gen.1.2!crossReference.b" osisRef="Gen.1.2" type="crossReference">
 <reference osisRef="Jer.4.23">Jer. 4:23</reference>
 </note>
 <w lemma="strong:H08414">without form</w>
 and
 <w lemma="strong:H0922">void</w>
 , and
 <w lemma="strong:H02822">darkness</w>
 was
 <w lemma="strong:H05921">over</w>
 the
 <w lemma="strong:H06440">face</w>
 of the
 <w lemma="strong:H08415">deep</w>
 . And the
 <w lemma="strong:H07307">Spirit</w>
 of
 <w lemma="strong:H0430">God</w>
 was
 <w lemma="strong:H07363">hovering</w>
 <w lemma="strong:H05921">over</w>
 the
 <w lemma="strong:H06440">face</w>
 of the
 <w lemma="strong:H04325">waters</w>
 .
 <div eID="gen6" type="paragraph" />
 </verse>
 <div type="x-milestone" subType="x-preverse" sID="pv2" />
 <div sID="gen7" type="paragraph" />
 <div type="x-milestone" subType="x-preverse" eID="pv2" />
 <verse osisID="Gen.1.3">
 And
 <w lemma="strong:H0430">God</w>
 <w lemma="strong:H0559">said</w>
 ,
 <note n="c" osisID="Gen.1.3!crossReference.c" osisRef="Gen.1.3" type="crossReference">
 <reference osisRef="2Cor.4.6">2 Cor. 4:6</reference>
 </note>
 <q level="1" marker="“" sID="01001003.1" />
 Let there
 <w lemma="strong:H01961">be</w>
 <w lemma="strong:H0216">light</w>
 ,
 <q eID="01001003.1" level="1" marker="”" />
 and there was
 <w lemma="strong:H0216">light</w>
 .
 </verse>
</div>