首页 新闻 会员 周边 捐助

处理json数据

0
悬赏园豆:30 [已解决问题] 解决于 2016-11-24 16:32

根据开始日期和结束日期计算出每个月请假的天数,把天数相加得到这个月的总请假天数并添加入json中,再添加一个月的字段,并存入json.把每个月的数据分别列出。

处理前的json数据:

{

    "success": true,

    "message": "读取成功!",

    "data": [

        {

            "docSubject": "123",

            "StartDate": "2016-04-11",

            "EndDate": "2016-04-14",

            "docStatus": "20",

            "URL": "ee"

        },

        {

            "docSubject": "test",

            "StartDate": "2016-03-25",

            "EndDate": "2016-03-26",

            "docStatus": "20",

            "URL": "2c3"

        },

        {

            "docSubject": "test",

            "StartDate": "2016-03-2",

            "EndDate": "2016-03-6",

            "docStatus": "20",

            "URL": "htta6294c56b32c3"

        },

        {

            "docSubject": "test",

            "StartDate": "2016-04-21",

            "EndDate": "2016-04-23",

            "docStatus": "20",

            "URL": "http://uatscop.shangha6294c56b32c3"

        },

        {

            "docSubject": "test",

            "StartDate": "2016-05-21",

            "EndDate": "2016-05-25",

            "docStatus": "20",

            "URL": "http://uatscop.shangha6294c56b32c3"

        }

    ]

}

 

处理后的json数据:

[

        {

            "count":7,

            "leaves": [

                {

                    "docSubject": "test",

                    "StartDate": "2016-03-2",

                    "EndDate": "2016-03-6",

                    "docStatus": "20"

                },

                {

                    "docSubject": "test",

                    "StartDate": "2016-03-25",

                    "EndDate": "2016-03-26",

                    "docStatus": "20"

                 }

            ],

            "month": "2016-03"

        },

        {

            "count": 7,

            "leaves": [

                {

                    "docSubject": "test",

                    "StartDate": "2016-05-21",

                    "EndDate": "2016-05-23",

                    "docStatus": "20",

                },

                {

                    "docStatus": "20",

                    "docSubject": "test",

                    "EndDate": "2016-04-11",

                    "StartDate": "2016-04-14"

                }

            ],

            "month": "2016-04"

        },

        {

            "count": 5,

            "leaves": [

                {

                    "docSubject": "test",

                    "StartDate": "2016-05-21",

                    "EndDate": "2016-05-25",

                    "docStatus": "20",

                }

            ],

            "month": "2016-05"

        }

 

    ]

青青子衿619的主页 青青子衿619 | 菜鸟二级 | 园豆:300
提问于:2016-11-07 17:00
< >
分享
最佳答案
1

反序列化成list.然后linq查询一下.

js就不会啦.不过js不是有linq.js吗.可以查一下.

收获园豆:20
吴瑞祥 | 高人七级 |园豆:29449 | 2016-11-07 17:14

不需要用插件,直接处理json数据

青青子衿619 | 园豆:300 (菜鸟二级) | 2016-11-07 17:24
其他回答(1)
0

js处理?js天生支持json,就像用类一样

收获园豆:10
顾晓北 | 园豆:10898 (专家六级) | 2016-11-09 16:33
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册