My Android application connects to Firebase and pulls out “Alert Objects” that are sent to my server.
When I export data from Firebase, I get a beautifully formed JSON representation of the data.
Problem: When I pull data to my Android device using DataSnapshot, the data has "=" (equal to signs) instead of ":" (semicolon). There are also no quotes.
When I try to do something like JSONObject alert = new JSONObject(data.getValue().toString()); I get errors for obvious reasons. I say, obviously, because if you look at what my code prints to the console, you can see that it is no longer in the actual JSON format.
A friend mentioned that I needed to do something with the encoding, but we did not have time to discuss this.
How can I iterate over these (curious) Alert objects that I created and turn them into JSON objects in my Java so that I can access their properties like alert.date and alert.message .
I thought the screenshots would help you understand what I am doing. Firebase is not protected at all, so you can freely look at it. It will not be very much, and when I go to production, I will transfer it anyway.




I'm sure this is a very simple question to answer, I'm just not too good at JSON and coding in general.
Thanks!
source share