最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Firebase database WEB get data in JSON - Stack Overflow

programmeradmin3浏览0评论

It is possible to get data from Firebase database from Javascript (WEB) directly in JSON format ?

Currently I'm using this function and I must to parse all data and convert it to JSON array

firebase.database().ref('posts/').once('value', function(snap){
        snap.forEach(function(obj){
            console.log(obj.val());
            // Parsing obj and saving to JSON array ...
        })
    })

It would be nice if I can get data directly in JSON format (like in Firebase console).

It is possible to get data from Firebase database from Javascript (WEB) directly in JSON format ?

Currently I'm using this function and I must to parse all data and convert it to JSON array

firebase.database().ref('posts/').once('value', function(snap){
        snap.forEach(function(obj){
            console.log(obj.val());
            // Parsing obj and saving to JSON array ...
        })
    })

It would be nice if I can get data directly in JSON format (like in Firebase console).

Share Improve this question asked Aug 2, 2016 at 16:45 DannyDanny 6922 gold badges11 silver badges21 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 6

What if you just JSON.stringify() it? Does that get you what you're looking for?

firebase.database().ref('posts/').once('value', function(snap){
    console.log(JSON.stringify(snap.val()))
})
发布评论

评论列表(0)

  1. 暂无评论