因此,这样做的方法是使用get\\u results作为OBJECT\\u K,stateid是查询的第一列。
然后我会对查询的点使用foreach将点添加到关联的状态?
我试图最终实现的是具有以下结构的JSON文件:
[
{
"stateid":"001",
"name":"Alaska",
"points":
{
"point":
[
{"id":"00001", "lat":"40.4038","lng":"-30.35263"},
{"id":"00002", "lat":"40.4013","lng":"-30.31355"},
{"id":"00003", "lat":"40.4023","lng":"-30.35235"},
]
}
"stateid":"002",
"name":"Alabama",
"points":
{
"point":
[
{"id":"00004", "lat":"41.4038","lng":"-31.35263"},
{"id":"00005", "lat":"42.4013","lng":"-32.31355"},
{"id":"00006", "lat":"43.4023","lng":"-33.35235"},
]
}
and so on for all of the states.
}]
也许只使用一个查询更好,那么所有具有的点都有一个与之关联的状态,但我只需要引用一个即可获得状态名称?我试图避免这种情况,因为这似乎是不必要的数据传输,但也许这比运行2个查询并编辑数组要好?