JSON数据结构问题

时间:2015-04-18 14:15:15

标签: android json listview android-listview

我正在创建一个包含json数据的应用程序。我正在收到像贝娄那样的json数据。

{
    "status": {
        "error": 0,
        "code": 0,
        "text": "success"
    },
    "data": [
        {
            "orders_id": "6",
            "date_purchased": "2015-01-19 02:47:16",
            "order_total": "$12.84",
            "order_items": [
                {
                    "item_id": "54",
                    "item_name": "Lunch-Box #1",
                    "item_qty": "1",
                    "item_price": "12.0000",
                    "item_tax_percent": "7.0000",
                    "attributes": [
                        {
                            "option": "Lunch",
                            "value": "add Corn",
                            "option_id": "52",
                            "value_id": "124",
                            "price": "2.0000",
                            "option_qty": "1"
                        }
                    ],
                    "item_dtls": {
                        "0": [],
                        "product_id": 54,
                        "product_name": "Lunch-Box #1",
                        "product_image": "",
                        "product_description": "Chicken caesar wrap with small soup",
                        "product_price": "10.00",
                        "special_price": "",
                        "delivery": "Y",
                        "base_price_from_attr": "N",
                        "base_price_attr_id": "0",
                        "default_attr_value_id": "0",
                        "attributes": [
                            {
                                "attr_id": "52",
                                "attr_name": "Lunch",
                                "quantitative": "Y",
                                "attr_values": [
                                    {
                                        "attr_value_id": "123",
                                        "attr_value_name": "Add Chicken",
                                        "attr_price": "0.00",
                                        "selected": 0
                                    },
                                    {
                                        "attr_value_id": "124",
                                        "attr_value_name": "add Corn",
                                        "attr_price": "2.00",
                                        "selected": 0
                                    }
                                ]
                            }
                        ]
                    },
                    "deal_id": "0",
                    "deal_products": []
                }
            ],
            "sub_totals": {
                "Sub-Total:": "12.00",
                "TAX 7.0%:": "0.84",
                "Tips:": "0.00",
                "Total:": "12.84"
            }
        }
    ]
}

但是我无法在arraylist或模型中构建数据,我还想通过使用上面的JSON数据创建可扩展的listview。可扩展列表视图的子项应包含标题列表视图,如设备中的联系人列表。

可展开的ListView结构:

Order Id:6
Order Total:$12.00
   **Item_name:Lunch-Box #1   Item_price: $10   Item_tax: 2%**
   Option: lunch
   Option: lunch
   **Item_name:Lunch-Box #1   Item_price: $10   Item_tax: 2%**
   Option: lunch
   **Item_name:Lunch-Box #1   Item_price: $10   Item_tax: 2%**
   **Item_name:Lunch-Box #1   Item_price: $10   Item_tax: 2%**

可以帮助我如何构建给定的JSON数据并创建可扩展的列表视图。如果可能请请一些代码或链接,我会得到一些提示。

1 个答案:

答案 0 :(得分:0)

This是我之前对另一个问题的回答,你可以参考构建你的json结构并获取数据。