retrieve firebase data as json

Viewed 19709

I would like to retrieve data stored in firebase database but in proper Json format, the problem is when using String.valueOf(dataSnapshot.getValue()) it is not the correct json format. For example, if the the data

{
  "properties" : {
     "last_update" : "15-02-2017 02:48:00 pm",
     "last_update_code" : "1258884"  
  } 
}

the returned value becomes like that

properties = {last_update = 15-02-2017 02:48:00 pm,last_update_code = 1258884}

without the quotes or (:) .

so it there a way to get the data as string in the first format?

5 Answers

Another possible method can be to use the URL based data read. If you you know the root which contains json file. Simply add .json to the end of the reference url of the node and it can be read as json file using the http. Consider the following as example. https://database-name.firebaseio.com/profiles/key.json The permission can be public or authorized and can be checked before making request.

Related