2013-09-05 60 views
0

招呼每一個我有文件JSON這樣的:我們如何能夠在JSON中獲取查詢

@service.json 
def get_data_physics(): 
    buuilding_name = ["Zone Test", "Zone Test sans Model"] * 299 
    data = { 
    "timestamp":["2012-12-08 00:04:53", "2012-12-08 00:09:53", "2012-12-08 00:14:54", "2012-12-08 00:19:54", "2012-12-08 00:24:54", "2012-12-08 00:29:54", "2012-12-08 00:34:54", "2012-12-09 23:00:46", "2012-12-09 23:05:46", "2012-12-09 23:10:46", "2012-12-09 23:15:46", "2012-12-09 23:20:46", "2012-12-09 23:25:46", "2012-12-09 23:30:46", "2012-12-09 23:35:46", "2012-12-09 23:40:46", "2012-12-09 23:45:47", "2012-12-09 23:50:47", "2012-12-09 23:55:47"], 
    "zone_name" : ["lieu Test"] * 575, 
    "building_name" : buuilding_name[0:575], 
    "outdoor":[3.6, 3.9, 3.6, 3.6, 3.6, 3.6, 3.6, 3.3, 3.6, 3.6, 3.3, 3.3, 3.3, 3.3, 3.3, 3.3, 3.3, 3.3, 3.3, 3.3, 3.3, 3.3, 3.3, 3.3, 3.3, 3.3, 3.3, 3.3, 3.3, 3.3, 3.3, 3.3, 3.3, 3.3, 3.3, 3.0, 3.0, 3.0, 3.0, 3.0, 3.0, 3.0, 3.0, 3.0, 3.0, 2.6, 2.6, 3.0, 2.6, 2.6, 2.6, 2.6, 2.6, 2.6, 2.6, 2.6, 2.6, 2.6, 2.6, 2.6, 2.6, 2.6, 2.6, 2.6, 2.6, 2.6, 2.6, 2.6, 2.6, 2.6, 2.6, 2.6, 2.3, 2.6, 2.3, 2.3, 2.6, 2.6, 2.6, 2.3, 2.6, 2.6, 2.6, 2.6, 2.6, 2.6, 1.0, 0.7, 0.7], 
    "indoor":[13.2, 13.2, 13.1, 13.1, 13.1, 13.1, 13.1, 13.0, 13.0, 13.0, 13.0, 13.0, 12.9, 13.0, 12.9, 12.9, 12.9, 12.9, 12.9, 12.9, 12.9, 12.8, 12.9, 12.8, 12.8, 12.8, 12.8, 12.8, 12.8, 12.8, 12.8, 12.7, 12.7, 12.7, 12.7, 12.7, 12.7, 12.7, 12.7, 12.7, 12.6, 12.7, 12.7, 12.6, 12.6, 12.6, 12.6, 12.6, 12.6, 12.6, 12.6, 12.6, 12.6, 12.6, 12.5, 12.5, 12.5, 12.5, 12.5, 12.5, 12.5, 12.5, 12.5, 12.5, 12.5, 12.4, 12.5, 12.4, 12.4, 12.4, 12.4, 12.4, 12.4, 12.4, 12.4, 12.4, 12.4, 12.4, 12.4, 12.4, 12.4, 12.4, 12.3, 12.3, 12.4, 12.3, 12.3, 11.7, 11.6, 11.7, 11.7, 11.7, 11.6, 11.6, 11.6, 11.6, 11.6, 11.6, 11.7, 11.6, 11.6, 11.6, 11.6, 11.6, 11.6, 11.6, 11.6, 11.6, 11.6, 11.6, 11.6, 11.6, 11.6, 11.6, 11.6, 11.5, 11.6, 11.6, 11.6, 11.5, 11.5, 11.6, 11.5, 11.5, 11.5, 11.5, 11.5, 11.5, 11.5, 11.5, 11.5, 11.5, 11.5, 11.5, 11.5, 11.5, 11.5, 11.5, 11.5, 11.5, 11.5, 11.5, 11.5, 11.4, 11.4, 11.5, 11.4, 10.9, 10.9, 10.8, 10.8, 10.9, 10.8, 10.9, 10.9, 10.9, 10.8, 10.8, 10.8, 10.8, 10.8, 10.9, 10.6, 10.6, 10.6, 10.6, 10.6, 10.6, 10.6, 10.6], 
    "energy":[41966.0, 41966.0, 41966.0, 41966.0, 41966.0, 41966.0, 41966.0, 41966.0, 41966.0, 41966.0, 41966.0, 41966.0, 41966.0, 41966.0, 41966.0, 41966.0, 41966.0, 41966.0, 41966.0, 41966.0, 41966.0, 41966.0, 41966.0, 41966.0, 41966.0, 41966.0, 41966.0, 41966.0, 41966.0, 41966.0, 41966.0, 41966.0, 41966.0, 41966.0, 41966.0, 41966.0, 41966.0, 41966.0, 41966.0, 41966.0, 41966.0, 41966.0, 41966.0, 41966.0, 41966.0, 41966.0, 41966.0, 41966.0, 41966.0, 41966.0, 41966.0, 41966.0, 41966.0, 41966.0, 41966.0, 41966.0, 41966.0, 41966.0, 41966.0, 41966.0, 41966.0, 41966.0, 41966.0, 41966.0, 41966.0, 41966.0, 41966.0, 41966.0, 41966.0, 41966.0, 41966.0, 41966.0, 41966.0, 41966.0, 41966.0, 41966.0, 41966.0, 41966.0, 41966.0, 41966.0, 41966.0, 41966.0, 41966.0, 41966.0, 41966.0, 41966.0, 41966.0, 41966.0, 41966.0, 41966.0, 41966.0, 41966.0, 41966.0, 41966.0, 41966.0, 41966.0, 41966.0, 41966.0, 41966.0, 41966.0, 41966.0, 41966.0, 41966.0, 41966.0, 41966.0, 41966.0, 41966.0, 41966.0, 41966.0, 41966.0, 41966.0, 41966.0, 41966.0, 41966.0, 41966.0, 41966.0, 41966.0, 41966.0, 41966.0, 41966.0, 41966.0, 41966.0, 41966.0, 41966.0, 41966.0, 41966.0, 41966.0, 41966.0, 41966.0, 41966.0, 41966.0, 41966.0, 41966.0, 41966.0, 41966.0, 41966.0, 41966.0, 41966.0, 41966.0, 41966.0, 41966.0, 41966.0, 41966.0, 41966.0, 41966.0, 41966.0, 41966.0, 41966.0, 41966.0, 41966.0, 41966.0, 41966.0, 41966.0, 41966.0, 41966.0, 41966.0, 41966.0, 41966.0, 41966.0, 41966.0, 41966.0, 41966.0, 41966.0, 41966.0, 41966.0, 41966.0, 41966.0, 41966.0, 41966.0, 41966.0, 41966.0, 41966.0, 41966.0, 41966.0, 41966.0, 41966.0, 41966.0, 41966.0, 41966.0, 41966.0, 41966.0, 41966.0, 41966.0, 41966.0, 41966.0, 41966.0, 41966.0, 41966.0, 41966.0, 41966.0, 41966.0, 41966.0, 41966.0, 41966.0, 41966.0, 41966.0, 41966.0, 41966.0, 41966.0, 41966.0, 41966.0, 41966.0, 41966.0, 41966.0, 41966.0, 41966.0, 41966.0, 41966.0, 41966.0, 41966.0, 41966.0, 41966.0, 41966.0, 41966.0, 41966.0, 41966.0, 41966.0, 41966.0, 41966.0, 41966.0, 41966.0, 41966.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0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], 
    } 
    print len(data["zone_name"]) 
    print len(data["building_name"]) 
    return data 

我想在我的JSON的查詢,但它不工作,這是我的代碼:

function createQueryCityName(strUser) { 
    var Query = $.getJSON("call/json/get_data_physics"); 
     console.log(Query); 
     query.setQuery("select building_name where indoor="+ 11.8); 
     return query; 
     console.log(response); 

你能告訴我什麼是我的問題嗎?

+2

直接調用它時,「call/json/get_data_physics」會返回什麼結果?將它提供給http://jsonlint.com以查看是否有任何語法問題。 – Blazemonger

+0

你可以把你的文章與服務器端語言,請? (Python?) –

+0

getJSON是異步的,它不是同步的。 「查詢」是世界上什麼都沒有定義的。 – epascarello

回答

2

您需要回撥。像

$.getJSON('call/json/get_data_physics', function(Query) { 

    console.log(Query); 

}); 
相關問題