How can I parse a JSON file from Assets folder in UWP - Closed How can I parse a JSON file from Assets folder in UWP - Closed json json

How can I parse a JSON file from Assets folder in UWP - Closed


You are probably looking for one of the innumerable JSON libraries. You should start with Json.Net, which is the most popular choice. (You can have a look at alternatives such as Service Stack Text, FastJsonParser or Jil).

A simple way would be to declare a class matching your expected data schema:

public class PointOfInterest{    public int Id { get; set; }    public string Name { get; set; }    // ...}

And the use deserialization.:

var poiArray = JsonConvert.DeserializeObject<PointOfInterest[]>(jsonString, new JsonSerializerSettings     {         ContractResolver = new CamelCasePropertyNamesContractResolver()     });

Edit so with your updated requirement you would have to do things like this :

var array = JArray.Parse(jsonString);foreach(JObject item in array){   var poi = new PointOfInterest()   poi.Id = (int)item.GetNamedNumber("id");   //...}

The official documentation is pretty straightforward.