JSON - 聚合和分组嵌套对象值

时间:2014-01-10 12:40:04

标签: javascript jquery json object nested

我有点时间平坦/映射这一点json。我已经设置了一个小提琴,所以你可以看到一个结构和我的预期输出的例子。基本上我需要计算每个接触点的动作计数,但是一旦我循环通过会话,一直让我失望的是,我似乎无法引用父“web”接触点来增加动作。

这是json和html的小提琴:http://jsfiddle.net/Michael_Ellan/Zjbdn/2/

这是原始的json:

{
"stages": {
    "proposition": "15%Off",
    "lifeCycleStages": [
        {
            "lifeCycleStage": "viewing",
            "touchpoints": [
                {
                    "touchpoint": "web",
                    "sessions": [
                        {
                            "actionCount": "2"
                        },
                        {
                            "actionCount": "0"
                        },
                        {
                            "actionCount": "0"
                        },
                        {
                            "actionCount": "3"
                        }
                    ]
                },
                {
                    "touchpoint": "mobile",
                    "sessions": [
                        {
                            "actionCount": "2"
                        },
                        {
                            "actionCount": "0"
                        },
                        {
                            "actionCount": "1"
                        }
                    ]
                }
            ]
        },
        {
            "lifeCycleStage": "buying",
            "touchpoints": [
                {
                    "touchpoint": "web",
                    "sessions": [
                        {
                            "actionCount": "2"
                        },
                        {
                            "actionCount": "0"
                        },
                        {
                            "actionCount": "0"
                        }
                    ]
                },
                {
                    "touchpoint": "mobile",
                    "sessions": [
                        {
                            "actionCount": "4"
                        },
                        {
                            "actionCount": "0"
                        },
                        {
                            "actionCount": "1"
                        }
                    ]
                }
            ]
        }
    ]
}
}

非常感谢任何反馈!

0 个答案:

没有答案
相关问题