[英]How to add dictionary items to jsonarray while in loop?
So I have a data structure like so...a dictionary... 所以我有一个像这样的数据结构...一个字典...
fbIds = ["him", "her", "it", "that"]
then I have a database i'm adding a json structure to... 然后我有一个数据库,我正在向其中添加一个json结构。
res = r.table("usa_nyc_bronx_merchants").insert({
"street_address": streetName.lower(),
"city": cityName.lower(),
"state": stateName.lower(),
"zipcode": zipcodeNumber.lower(),
"county": countyName.lower(),
"fbIds": [ADD DICTIONARY ITEMS TO THIS ARRAY]
.....
How do i add the items in that dictionary into that that json array...mind you all this code is already in a for loop. 我如何将字典中的项目添加到该json数组...请注意,所有这些代码已经在for循环中。
Thanks! 谢谢!
fbIds
is already an array ( list
in python terms). fbIds
已经是一个数组(以python术语list
)。 So you should be able to just do: 因此,您应该能够做到:
res = r.table("usa_nyc_bronx_merchants").insert({
"street_address": streetName.lower(),
"city": cityName.lower(),
"state": stateName.lower(),
"zipcode": zipcodeNumber.lower(),
"county": countyName.lower(),
"fbIds": fbIds
.....
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.