Skip to content
Advertisement

JSON does not show id from DB

I returned the data from my firebase database in a JSON file with PHP CURL but it doesn’t show me the id of the records

my code:

JavaScript

my data base

enter image description here

Advertisement

Answer

That’s because Firebase interprets your sequential, numerical keys as array indices, and returns the results as a JSON array.

If you want to prevent Firebase from performing this conversion, make sure your keys aren’t sequential numbers, for example by prefixing them with a short fixed string:

JavaScript

Also see: Best Practices: Arrays in Firebase.

User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement