我们如何在json中获取查询

时间:2013-09-05 13:13:21

标签: jquery python 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.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, 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);
你可以告诉我我的问题是什么吗?

1 个答案:

答案 0 :(得分:2)

你需要一个回调。这样做

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

    console.log(Query);

});