I am new to firebase, and I am trying to put JSON object data into my Firebase. I know how to put data as a class object into Firebase, but I want to put JSON object data.
Is there any way to put JSON object data into Firebase without converting it as a POJO?
Yes, you can achieve this. Start by converting your json to a string then do the following:
String jsonString; //set to json string
Map<String, Object> jsonMap = new Gson().fromJson(jsonString, new TypeToken<HashMap<String, Object>>() {}.getType());
I am using the "updateChildren" method because I want the JSON object added directly to the root of my child object
firebaseDatabaseRef.child("users").child(uid).updateChildren(jsonMap);
If you don't care or you would like to set a new node, use
firebaseDatabaseRef.child("users").child(uid).child({your new node}).setValue(jsonMap);