Using (var reader = new StreamReader(stream)) Var assembly = this.GetType().GetTypeInfo().Assembly Īssembly.GetManifestResourceStream("data.json") // make sure you inset the full After a fair bit of tweaking, I came up with a solution to do what the ASP.NET code did: public List Data That wasn’t working for me in an app, though. I now have a C# list of all my json objects and can do whatever I like with them now. Return Data = JsonConvert.DeserializeObject>(kJson) ![]() String kJson = File.ReadAllText(path: "data.json") I have my json in a local file and for ease of demonstration in the same folder as my main class, which is calling the following: Let’s say we have created a C# object called Mountain to model the data. Here’s how you would do it in ASP.NET or a simple Console app. ![]() ![]() Well, the answer is that yes, it is, but it is slightly different to how it’s done in an ASP.NET or other C# app. I already had all the data, so it would be easy to consume in a Xamarin app, right? Until, one day I thought that this would be a good idea for a mobile app. The app was really more of a practise thing than anything else and I sort of forgot about it. A while back, I wrote around 200 JSON objects out to provide a data source for a web app that I was writing that would allow the user to track the mountains that they had climbed.
0 Comments
Leave a Reply. |