在我的控制器I m 带宽(称为c.order_history
)。 参看:
[
{
"status": [
{
"status": "created",
"timestamp": "2012-04-06 00:14:10"
},
{
"status": "authed",
"timestamp": "2012-04-06 00:14:17"
}
注,
"product_info": [
{
"id": 3,
"quantity": 1,
"created": "2012-04-06 00:14:10",
"image_id": 13341
},
{
"id": 2,
"quantity": 1,
"created": "2012-04-06 00:14:10",
"image_id": 13323
},
{
"id": 1,
"quantity": 1,
"created": "2012-04-06 00:14:10",
"image_id": 13322
}
注,
"shipping_charge": "0.00",
"order_number": "0723094747433",
"shipping_address": {
"country_code": null,
"extended_address": "Unit Z",
"locality": "Las Vagas",
"company": null,
"phone": null,
"postal_code": "31415",
"full_name": "Boris Karloff",
"nickname": null,
"region": "NV",
"street_address": "123 Random Way"
},
"subtotal": "59.00"
}
注
I m经json.loads (order_history)
通过,将其变成一个字典,然后试图提取每个钥匙,然后我就可以在其中获取随后的关键/价值,如:
c.product_info = [{ product_info : product_info} for product_info in c.order_history注
Which outputs the entire json string, but it s just named product_info
now. Can someone steer me in the right direction on how I can access say, the timestamp
value, product_info[0注[ image_id 注
and shipping_address
values, etc.?