我有一个对象列表pi@raspberrypi ~ $ sudo pip-3.2 install requests
Downloading/unpacking requests
Downloading requests-2.11.1.tar.gz (485Kb): 485Kb downloaded
Running setup.py egg_info for package requests
warning: no files found matching 'test_requests.py'
Installing collected packages: requests
Running setup.py install for requests
warning: no files found matching 'test_requests.py'
File "/usr/local/lib/python3.2/dist-packages/requests/models.py", line 856
http_error_msg = u'%s Client Error: %s for url: %s' % (self.status_code, reason, self.url)
^
SyntaxError: invalid syntax
Successfully installed requests
Cleaning up...
,有一些值如:
Day
-id
-name
-List of objects `Meal`
对象有:
Meal
-id
-meal number
-List of objects `Product`
对象有:
Product
我发送到-id
-name
-cost
的应用程序列表,示例字符串:
Day
看起来像:
-two `Days`
-two `Meals` for every `Day`
-three `Products` for every `Meal`
如何从此字符串中获取相同的对象结构?
我知道可能有一种方法是使用[
{
"id": 1,
"name": "firstDayName",
"meal": [
{
"id": 2,
"mealNumber": 0,
"product": [
{
"id": 4,
"name": "exampleName1"
},
{
"id": 5,
"name": "exampleName2"
},
{
"id": 6,
"name": "exampleName3"
}
]
},
{
"id": 7,
"mealNumber": 1,
"product": [
{
"id": 8,
"name": "exampleName4"
},
{
"id": 9,
"name": "exampleName5"
},
{
"id": 10,
"name": "exampleName6"
}
]
}
]
},
{
"id": 11,
"name": "secondDayName",
"meal": [
{
"id": 12,
"mealNumber": 0,
"product": [
{
"id": 14,
"name": "exampleName10"
},
{
"id": 15,
"name": "exampleName20"
},
{
"id": 16,
"name": "exampleName30"
}
]
},
{
"id": 17,
"mealNumber": 1,
"product": [
{
"id": 18,
"name": "exampleName40"
},
{
"id": 19,
"name": "exampleName50"
},
{
"id": 20,
"name": "exampleName60"
}
]
}
]
}
]
,但不知道该怎么做。