Currently i am using unity to post comments that get saved in a firebase RTDB.
here is the posting code:
Comment NewComment = new Comment("User1", "Great App!");
Dictionary<string, System.Object> childUpdates = new
Dictionary<string, System.Object>();
childUpdates["NewUpdate2"] = NewComment.ToDict();
_database.GetReference("DumbData").UpdateChildrenAsync(childUpdates);
which works well and posts the data to Firebase
For reference here is the Comment Class.
[System.Serializable]
public class Comment
{
public Comment(string Name,string Content)
{
this.Name = Name;
this.Content = Content;
}
public Dictionary<string,System.Object> ToDict()
{
Dictionary<string, System.Object> result = new Dictionary<string, System.Object>();
result["Name"] = this.Name;
result["Content"] = this.Content;
return result;
}
public string Name;
public string Content;
}
and the firebase registers the data received correctly.
but then when receiving the data, i would do
var dataSnapShot = await _database.GetReference("DumbData").GetValueAsync();
var Results = dataSnapShot.GetRawJsonValue();
var temp= JsonUtility.FromJson<Dictionary<string, Comment>>(Results)
but the thing is the FromJSON function returns Nulls everywhere , although the JSON is received correctly matching the structure on Firebase, for reference, the Results variable above looks like this:
{"NewUpdate":{"Content":"Great App!","Name":"User1"},"NewUpdate2":{"Content":"Great App!","Name":"User2"}}
so that's where i am stuck, i cannot deseriazlize the response back to be able to use it.
question from:
https://stackoverflow.com/questions/65857823/deserializing-json-response-from-unitys-firebask-sdk-error 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…