Read Data from Json file
Step 1 Past json format to text file save as .json
Step 2 add file in to pcl
Step 3 Right click the file and Select properties
Step 4 Change Build action to Embedded Resource
Step 5 Add this method to ViewModel
private void GetJsonData()
{
try
{
var _tempdata = new ResponseData();
string jsonFileName = "gold_sample_response.json";
var assembly = typeof(CurrentViewModelname).GetTypeInfo().Assembly;
Stream stream = assembly.GetManifestResourceStream($"{assembly.GetName().Name}.{jsonFileName}");
using (var reader = new System.IO.StreamReader(stream))
{
var jsonString = reader.ReadToEnd();
ResponseData _overalltempdata = JsonConvert.DeserializeObject<ResponseData>(jsonString);
List = _overalltempdata.getrecruitementcalendarjobdetail;
}
}
catch (Exception ex)
{
}
}
Step 2 add file in to pcl
Step 3 Right click the file and Select properties
Step 4 Change Build action to Embedded Resource
Step 5 Add this method to ViewModel
private void GetJsonData()
{
try
{
var _tempdata = new ResponseData();
string jsonFileName = "gold_sample_response.json";
var assembly = typeof(CurrentViewModelname).GetTypeInfo().Assembly;
Stream stream = assembly.GetManifestResourceStream($"{assembly.GetName().Name}.{jsonFileName}");
using (var reader = new System.IO.StreamReader(stream))
{
var jsonString = reader.ReadToEnd();
ResponseData _overalltempdata = JsonConvert.DeserializeObject<ResponseData>(jsonString);
List = _overalltempdata.getrecruitementcalendarjobdetail;
}
}
catch (Exception ex)
{
}
}
Comments
Post a Comment