Sullan
Sullan

Reputation: 1157

Convert nested list to a JSON stream

I am struggling to collect data from a nested list. The list looks something like this

http://jsfiddle.net/Sullan/k7vSg/1/

From this list I am trying to create a JSON result which is similar to this

{
   "coreservices":[
      {
         "title":"Review",
         "review":"Quaterly",
         "scheduled":[
            {
               "date1":"February",
               "date2":"February 11"
            },
            {
               "date1":"August",
               "date2":"August 6"
            }
         ]
      },
      {
         "title":"Analysis",
         "review":"Semi-Annually",
         "scheduled":[
            {
               "date1":"March",
               "date2":"March 22"
            },
            {
               "date1":"May",
               "date2":"May 10"
            }
         ]
      }
   ],
   "functions":[
      {
         "title":"Communication",
         "review":"Semi-Annually",
         "scheduled":[
            {
               "date1":"February",
               "date2":"February 11"
            },
            {
               "date1":"August",
               "date2":"August 6"
            }
         ]
      },
      {
         "title":"Meeting",
         "review":"Semi-Annually",
         "scheduled":[
            {
               "date1":"March",
               "date2":"March 22"
            },
            {
               "date1":"May",
               "date2":"May 10"
            }
         ]
      }
   ]
}

It would be of great help if anybody direct me on how to achieve this. Thanks in advance

Upvotes: 0

Views: 1463

Answers (1)

isotrope
isotrope

Reputation: 1847

Please try the following jsfiddle to see if it brings you close to what you need: http://jsfiddle.net/k7vSg/2/

It's quick and dirty, but I'm hoping it'll help you.

Cheers, iso

Upvotes: 4

Related Questions