我查询过后,可以操作FDatasnapshot吗? [英] Can I manipulate FDatasnapshot once I have queried for it?

查看:95
本文介绍了我查询过后,可以操作FDatasnapshot吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我希望能够在我回来的Datasnapshot上做一些自定义的过滤。我不认为我可以创建一个复杂的查询来完成我想要的结果。

这是可能的,如果是这样的话,什么是解析快照?

编辑:

我正在使用SwiftyJSON,这是我最终解析它:

p>

  standbyRef.observeSingleEventOfType(.Value,withBlock:{snapshot in 
// do some stuff once

println(snapshot.value)
self.parseJson(snapshot.value as NSDictionary)

$)
$ b func parseJson(var snapshot:NSDictionary!){

让json = JSON(快照)
$ b $在json中的(key:String,subJson:JSON){
//待机用户的密钥
println(key)

//一个对象一次
println(subJson)
}

}
JSON中的所有数据
格式只。当您获取Firebase的任何特定节点的 Datasnapshot 时,您将获得该节点下的完整数据,仅在所有JSON中都有。



一旦获得 Datasnapshot JSON ,您可以使用任何 JSON 库来解析它,具体取决于您使用的平台。

您可以在这里参考 Datasnapshot Methods 获取更多信息。


I want to be able to do some custom filtering on the Datasnapshot I get back. I don't think I can create a complex query to accomplish the result I want.

Is this possible to do and if so, what is the best way of parsing the snapshot?

EDIT:

I am using SwiftyJSON and this is how I ended up parsing it:

standbyRef.observeSingleEventOfType(.Value, withBlock: { snapshot in
        // do some stuff once

        println(snapshot.value)
        self.parseJson(snapshot.value as NSDictionary)

})

func parseJson(var snapshot:NSDictionary!){

    let json = JSON(snapshot)

    for (key: String, subJson: JSON) in json {
        // key to standby users
        println(key)

        // one object at a time
        println(subJson)
    }

}

解决方案

Firebase accepts all the data in JSON format only. When you get a Datasnapshot of any perticular node of Firebase, you get the complete data below that node, which is in all a JSON only.

Once you get the Datasnapshot JSON you can parse it using any JSON library, depending on the platform you use.

You can refer here Datasnapshot Methods for more info.

这篇关于我查询过后,可以操作FDatasnapshot吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆