I've the following unordered list:
<ul class="primary">
<li id="1"><span>Product Family A</span>
<ul class="secondary">
<li><span>A.1</span></li>
<li><span>A.2</span></li>
</ul>
</li>
<li id="2"><span>Product Family B</span>
<ul class="secondary">
<li><span>B.1</span></li>
</ul>
</li>
etc...
</ul>
I'd like to generate the output below with jQuery. Can someone help?
product_family:[{
id:1,
products:[{
model: A1,
model: A2
}],
product_family:[{
id:2,
products:[{
model: B1
}]
THanks!
product_familyandmodelwithin the same object, the second instance will just blow away the first. You're trying to treat JSON like XML and you can't.