KnottyDreadLox
KnottyDreadLox

Reputation: 39

Xamarin Firebase - GetData failling with imported Json database

I have a bit of a severely confusing issue that I have been trying to solve for a week now and it's gotten to the point of frustration...

After much troubleshooting and trying different ways, I have concluded that the issue is coming from my imported Firebase JSON.

So I followed everything exactly as it is in this tutorial My code is exactly this: https://www.c-sharpcorner.com/article/xamarin-forms-working-with-firebase-realtime-database-crud-operations/

And it works, I can add/search/load/delete etc. it shows in my Firebase database and all is dandy. It saves it to my Firebase as this format

enter image description here

HOWEVER

when I change my firebase database, so I import my own JSON in the same format as it is being saved, like this for instance. I make sure about the String and/or Int difference.

enter image description here enter image description here

and suddenly the same code that worked before now does not work and throws me the error because I've used my own JSON Firebase.Database.FirebaseException: 'Exception occurred while processing the request.

enter image description here

Can someone help me before I rip my hair out :P

Thank you all

Upvotes: 0

Views: 119

Answers (1)

Elvi Xhaferri
Elvi Xhaferri

Reputation: 195

I think you need to create a Model(for deserializing your response)
1-Persons.cs
public string Name {get; set;}
public int studentId {get; set;}
2-string json = @"{
  "Name":"Mark",
   "PersonID": 11,
  ]
}";
Student student= JsonConvert.DeserializeObject<Student>(json);

Upvotes: 3

Related Questions