Articles in this section
Category / Section

How to bind JSON data in Xamarin DataForm?

1 min read

You can bind the data from JSON (JavaScript Object Notation) in Xamarin DataForms.


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; }



Convert String type into DateTime type when adding items to the local collection from JSON data model, since JSON does not support DateTime type.


Create data for the data model.

//// Add data for JSON data model
private string JsonData =
          "[{\"UserName\": \"Chan\",\"UserGender\": \"Male\",\"UserMail\": \"\",\"UserCountry\": \"Japan\", \"UserBirthDate\": \"05/01/1996\"}]";


Deserialize the JSON data as list of JSON data model.

List<JSONData> jsonDataCollection = JsonConvert.DeserializeObject<List<JSONData>>(JsonData);


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);


A screenshot of a cell phone

Description automatically generated

View Sample in GitHub


I hope you enjoyed learning how to bind JSON data in Xamarin Data Form.

You can refer to our Xamarin DataForms feature tour page to know about its other groundbreaking feature representations and documentation, and how to quickly get started for configuration specifications. You can also explore our Xamarin dataForms example to understand how to create and manipulate data.

For current customers, you can check out our components from the License and Downloads page. If you are new to Syncfusion, you can try our 30-day free trial to check out our other controls.

If you have any queries or require clarifications, please let us know in the comments section below. You can also contact us through our support forumsDirect-Trac, or feedback portal. We are always happy to assist you!

Did you find this information helpful?
Help us improve this page
Please provide feedback or comments
Comments (0)
Please sign in to leave a comment