JOHN JOHNNNY

JOHN JOHNNNY

  • NA
  • 190
  • 139.7k

Help with JSON file reading

Jan 16 2015 9:33 AM
Hi
I have this jason file located in my Assets/Dec1.js how can i make it appear in my textblock
when i run it in the emulator it shows "This" instead of showing the content in the Assets/Dec1.js
Kindly help
see the code below
xaml
<ScrollViewer>
                <TextBlock x:Name="textblock" TextWrapping="Wrap" Foreground="White"/>
            </ScrollViewer>

xaml.cs
//JSON starts here
        public string ReadJsonFile(string JsonfilePath)
        {
            string strText = "This";
            using (StreamReader r = new StreamReader("Assets/Dec1.js"))
            {
                string json = r.ReadToEnd();
                dynamic array = JsonConvert.DeserializeObject(json);
                //... read text from json file
                 
            }
            return strText;
           
        }
        //Daily Devotion starts here
        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
            AddDevotions();
            int index = DateTime.Now.DayOfYear;
            textblock.Text = devotions[index];
        }
        List<String> devotions = new List<string>();
        private void AddDevotions()
        {
  devotions.Add(ReadJsonFile("Assets/Dec1.js"));
            devotions.Add(ReadJsonFile("Assets/Dec1.js"));
            devotions.Add(ReadJsonFile("Assets/Dec1.js"));
   }

Thank you in advance and reply soon

Answers (18)