将嵌套列表转换为JSON流

时间:2012-02-23 15:18:40

标签: jquery json

我正在努力从嵌套列表中收集数据。该列表看起来像这样

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

从这个列表中我试图创建一个与此

类似的JSON结果
{
   "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"
            }
         ]
      }
   ]
}

如果有人指导我如何实现这一点,那将是非常有帮助的。提前致谢

1 个答案:

答案 0 :(得分:3)

请尝试以下jsfiddle,看看它是否能满足您的需求:http://jsfiddle.net/k7vSg/2/

这很快又很脏,但我希望它会帮助你。

干杯, 异