2X faster development
The ultimate Xamarin UI toolkit to boost your development speed.
You can bind the data from JSON (JavaScript Object Notation) in Xamarin.Forms C# Create a JSON data model. /// <summary> /// Represents custom data properties. /// </summary> public class JSONData { public string UserName { get; set; } public string UserGender { get; set; } public string UserMail { get; set; } public string UserCountry { get; set; } }
Note: Convert String type into DateTime type when adding items to the local collection from JSON data model, since JSON does not support DateTime type. C# Create data for the data model. //// Add data for JSON data model private string JsonData = "[{\"UserName\": \"Chan\",\"UserGender\": \"Male\",\"UserMail\": \"chan@yyy.com\",\"UserCountry\": \"Japan\", \"UserBirthDate\": \"05/01/1996\"}]"; C# Deserialize the JSON data as list of JSON data model. List<JSONData> jsonDataCollection = JsonConvert.DeserializeObject<List<JSONData>>(JsonData); C# Load the JSON data list into the DataForm model. foreach (var data in jsonDataCollection) { this.ContactsInfo.Name = data.UserName; this.ContactsInfo.Gender = data.UserGender; this.ContactsInfo.Email = data.UserMail; this.ContactsInfo.Country = data.UserCountry; this.ContactsInfo.DateOfBirth = Convert.ToDateTime(data.UserBirthDate); } Output |
2X faster development
The ultimate Xamarin UI toolkit to boost your development speed.
This page will automatically be redirected to the sign-in page in 10 seconds.