Hi
I am developing wp8 devotional app my questions are
1. How can i write a code to read the json/text file for each day's devotional locally
This is my code below
xaml
xaml.cs
protected override void OnNavigatedTo(NavigationEventArgs e)
{
AddDevotions();
int index = DateTime.Now.DayOfYear;
textblock.Text = devotions[index];
}
List
private void AddDevotions()
{
devotions.Add("4 Faith works miracles");
devotions.Add("5 Faith works miracles");
devotions.Add("6 Faith works miracles");
devotions.Add("7 Faith works miracles");
devotions.Add("8 Faith works miracles");
devotions.Add("9 Faith works miracles");
devotions.Add("10 Faith works miracles");
// add 366 days
}
Thank you in advance and reply soon
JOHN JOHNNNYPosted Jan 16, 2015, 3:56 AM
Thank you for the reply i appreciate, but what if i want to use it in my xaml.cs code above how am i to go about it.
I have not used json in project before am just starting out using it, kindly help
Thank you and reply soon
Bhushan GawalePosted Jan 16, 2015, 2:34 AM
using (StreamReader r = new StreamReader("jsonfile"))
{
string json = r.ReadToEnd();
dynamic array = JsonConvert.DeserializeObject(json);
}
JsonConverter is the provider given by Nuget called as Json.net - you will need to install it in your project.
Michal HabalcikPosted Jan 15, 2015, 12:54 PM
C# Meets JSON: Lightweight Data-Interchange Format Explained