4

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).

1 Answer 1

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()))
})
Sign up to request clarification or add additional context in comments.

1 Comment

You're right ! It was really stupid question. Thank you !

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.