I have data in markup like this:
<p class="bbook">Lorem</p>
<p class="bref">
<a class="ref" href="prin.v.ii.ii.html">2:15</a>
<a class="ref" href="prin.v.i.v.html">3:17-19</a>
<a class="ref" href="prin.v.v.html">3:19 </a>
</p>
<p class="bbook">Ipsum</p>
<p class="bref">
<a class="ref" href="sec.vii.xxii.html">10:18</a>
<a class="ref" href="sec.vii.ix.html">10:27</a>
<a class="ref" href="sec.vii.xxiii.html">10:28</a>
</p>
I'd like to convert it to a JSON object like this:
{
"Lorem": {
"prin.v.ii.ii.html": "2:15",
"prin.v.i.v.html": "3:17-19",
"prin.v.v.html": "3:19"
},
"Ipsum": {
"sec.vii.xxii.html": "10:18",
"sec.vii.ix.html": "10:27",
"sec.vii.xxiii.html": "10:28"
}
}
I've seen some HTML to JSON solutions here but none that I can find that deal with attributes. I know it might be easier if the markup had ul
's but it doesn't. How could I convert this?