使用laravel创建嵌套的JSON

时间:2019-06-01 09:34:45

标签: mysql json laravel

我想使用Laravel创建以下json格式。我不是在说雄辩。 Json as。请对如何获取json进行编码。

{
    "success": "1",
    "data": [
        {
            "state_id": 1,
            "state_name": "M",
            "district": [
                {
                    "district_id": 1,
                    "district_name": "k",
                    "taluka": [
                        {
                            "taluka_id": 1,
                            "taluka_name": "k",
                            "village": [
                                {
                                    "village_id": 1,
                                    "village_name": "v",
                                    "area": [
                                        {
                                            "area_id": 1,
                                            "village_id": 1,
                                            "area_name": "j"
                                        }
                                    ]
                                }
                            ]
                        }
                    ]
                },
                {
                    "district_id": 2,
                    "district_name": "s",
                    "taluka": [
                        {
                            "taluka_id": 2,
                            "taluka_name": "w",
                            "village": [
                                {
                                    "village_id": 2,
                                    "village_name": "a",
                                    "area": [
                                        {
                                            "area_id": 2,
                                            "village_id": 2,
                                            "area_name": "g"
                                        }
                                    ]
                                }
                            ]
                        }
                    ]
                }
            ]
        },
        {
            "state_id": 2,
            "state_name": "G",
            "district": []
        }
    ]
}

0 个答案:

没有答案