private static List<Page> ParseJPages(JArray pagesArray, Issue i)
 {
     List<Page> ret_list = new List<Page>();
     WebClient wc = new WebClient();
     if (pagesArray != null && pagesArray.Count > 0)
     {
         foreach (JObject obj in pagesArray)
         {
             String partialPath = ((String)obj["url"]).Remove(((String)obj["url"]).IndexOf(".json"));
             Page p = new Page();
             p.url = (String)obj["url"];
             Issue i1 = new Issue();
             i1.url = i.url;
             i1.local_url = i.local_url;
             i1.date_issued = i.date_issued;
             i1.local_url = reloutput3 + ".json";
             p.issue = i1;
             p.jp2 = partialPath + ".jp2";
             p.ocr = partialPath + "/ocr.xml";
             p.pdf = partialPath + ".pdf";
             p.sequence = (int)obj["sequence"];
             p.text = partialPath + "/ocr.txt";
             p.title = i.title;
             //writing the page file
             output4 = output3 + ".Page" + p.sequence;
             reloutput4 = reloutput3 + ".Page" + p.sequence;
             p.local_url = reloutput4 + ".json";
             file = new System.IO.StreamWriter(output4 + ".json");
             String output = JsonConvert.SerializeObject(p, Formatting.Indented);
             file.WriteLine(output);
             file.Close();
             ret_list.Add(p);
         }
     }
     return ret_list;
 }
        /**
         * Parses all the issues by an awardee
         */
        private static List<Issue> ParseJIssues(JArray issuesArray)
        {
            List<Issue> ret_list = new List<Issue>();
            WebClient wc = new WebClient();
            if (issuesArray != null && issuesArray.Count > 0)
            {
                foreach (JObject obj in issuesArray)
                {
                    try
                    {
                        Stream data = wc.OpenRead((String)obj["url"]);
                        StreamReader reader = new StreamReader(data);
                        string s = reader.ReadToEnd();
                        JObject jobj = JObject.Parse(s);
                        JArray pagesArray = (JArray)jobj["pages"];
                        Issue i = new Issue();
                        Batch b = new Batch();
                        b.url = (String)(((JObject)jobj["batch"])["url"]);
                        b.name = (String)(((JObject)jobj["batch"])["name"]);
                        b.local_url = reloutput2 + ".json";
                        i.batch = b;
                        i.date_issued = (String)obj["date_issued"];
                        i.volume = (String)jobj["volume"];
                        i.edition = (int)jobj["edition"];
                        i.number = (String)jobj["number"];
                        Title t = new Title();
                        JObject temp = (JObject)obj["title"];
                        t.name = (String)temp["name"];
                        t.url = (String)temp["url"];
                        i.title = t;
                        i.url = (String)obj["url"];
                        output3 = output2 + "." + t.name.Remove(t.name.Length - 1) + "-" + i.date_issued;
                        reloutput3 = reloutput2 + "." + t.name.Remove(t.name.Length - 1) + "-" + i.date_issued;
                        i.local_url = reloutput3 + ".json";
                        i.pages = new List<Page>();
                        foreach (JObject pobj in pagesArray) //parsing only necessary fields here to avoid redundancy in data
                        {
                            Page p = new Page();
                            p.sequence = (int)pobj["sequence"];
                            p.url = (String)pobj["url"];
                            p.local_url = reloutput3 + ".Page" + p.sequence + ".json";
                            i.pages.Add(p);
                        }

                        //writing to the Issue file
                        file = new System.IO.StreamWriter(output3 + ".json");
                        String output = JsonConvert.SerializeObject(i, Formatting.Indented);
                        file.WriteLine(output);
                        file.Close();
                        ret_list.Add(i);
                        ParseJPages(pagesArray, i);
                    }
                    catch (Exception e)
                    {
                        continue;
                    }
                }
            }
            return ret_list;
        }