I have a JSON object that is coming back based on the keyword that the user type. It is returning only some of the typed keyword from the user. When I check postman and type the same keyword it returns properly.
The following exception is raised:
Newtonsoft.Json.JsonSerializationException:
Must specify valid information for parsing in the string
JSON
{
"valid": true,
"result": {
"points": [
{
"pointId": "505",
"name": "Building one",
"description": "Office of Technology and Data Application Development",
"latitude": "xxx",
"longitude": "xxx",
"floor": "B",
"aliases": [],
"comments": [],
"images": []
}
],
"categories": []
},
"errors": []
}
Model classes
public class SearchPoints
{
public bool Valid { get; set; }
public Result Result { get; set; }
public List<string> Errors { get; set; }
}
public class Result
{
public List<Point> Points { get; set; }
public List<Category> Categories { get; set; }
}
public class Category
{
public long CategoryId { get; set; }
public string Name { get; set; }
public long ParentId { get; set; }
public string Parent { get; set; }
}
public class Point
{
public long PointId { get; set; }
public string Name { get; set; }
public string Description { get; set; }
public string Latitude { get; set; }
public string Longitude { get; set; }
public Floor Floor { get; set; }
public List<string> Aliases { get; set; }
public List<string> Comments { get; set; }
public List<string> Images { get; set; }
}
public enum Floor
{
A,
B
};
Service method
var apiResponse = await _httpClient.GetAsync(Url + _keyword);
var apiContent = apiResponse.Content.ReadAsStringAsync().Result;
var pointsJsonResponse = JsonConvert.DeserializeObject<SearchPoints>(apiContent);
var potentialPoints = new ObservableCollection<Point>(pointsJsonResponse.Result.Points);
PointsItemSource = potentialPoints;