Hello I have a big JSON file representing countries and their total cases and deaths from covid. All I want to do is to display the data of the JSON in to my AboutPage. I have tried various ways, but no-one is working for me. Any idea how I should work?
I am giving you a small part of the JSON
[{
"regionData": [
{
"country": "World",
"totalCases": 157341642,
"newCases": 651328,
"totalDeaths": 3278509,
"newDeaths": 9126,
"totalRecovered": 135480211,
"activeCases": 18582922,
"seriousCritical": 108879,
"casesPerMil": 20185,
"deathsPerMil": 420.6,
"totalTests": 0,
"testsPerMil": 0,
"population": 0
},
{
"country": "India",
"totalCases": 21886556,
"newCases": 401271,
"totalDeaths": 238265,
"newDeaths": 4194,
"totalRecovered": 17917013,
"activeCases": 3731278,
"seriousCritical": 8944,
"casesPerMil": 15729,
"deathsPerMil": 171,
"totalTests": 298601699,
"testsPerMil": 214596,
"population": 1391457000
}, ]
}]
var assembly = typeof(AboutPage).GetTypeInfo().Assembly; Stream stream = assembly.GetManifestResourceStream("MaybeThisOne.testmodel.json");
using (var reader = new System.IO.StreamReader(stream))
{
var json = reader.ReadToEnd();
List<TestModel> mylist = JsonConvert.DeserializeObject<List<TestModel>>(json);
myrootobject = new ObservableCollection<TestModel>(mylist);
MyListView.ItemsSource = myrootobject;
JsonConvert.DeserializeObject<List> In this part i have error saying cannot be used like method. I tried to remove the parenthesis but nothing happened
UPDATED:
I did the steps that were suggested, 1. create a C# model using json2csharp.com, 2. deserialize using newtonsoft. The build is happening and the app starts, but when I try to enter the created page, it terminates the app without any error message.
UPDATED 2:
I started a new project and followed the above steps. The only error I get is about Page3. I have to call it in the shell from jsonarray folder. How should I do it?
e.x <ShellContent Title="About" Icon="icon_about.png" Route="AboutPage" ContentTemplate="{DataTemplate local:AboutPage}" />
Please can you tell me how should I call Page3 from jsonarray folder? Thanks in advance!!!
UPDATE 3
I have started the project from scratch and it partially worked. The only problem is that it doesn't show all the binding fields.
Any idea?