title: Parsing Json Windows8
body: <p>I have tried multiple ways to parse json in Windows 8 and i m getting this error alot.</p>
  
  <p>"WinRT information: WEB_E_INVALID_JSON_STRING"</p>
  
  <p>It gets to a point that i use the same json string, and it works (more or less) if i read from  it from the web, but it won't work if i read it from a local file.</p>
  
  <p>heres the code to read it from the web:</p>
  
  <pre><code> public async void ExamineJson()
      {
          string responseText = await GetjsonStream();
          ParseJson(responseText);
      }
  
  
  public async Task&lt;string&gt; GetjsonStream()
      {
          HttpClient client = new HttpClient();
          string url = "http://rmarinho.facilit.us/app/d/rtp/config.json";
          HttpResponseMessage response = await client.GetAsync(url);
          return response.Content.ReadAsString();
      }
  
  
  
      private static void ParseJson(string responseText)
      {
          JsonObject root = new JsonObject(responseText);
          string epg = root.GetNamedString("epgurl");
  
          JsonArray themes = root["themes"].GetArray();
  
          for (int i = 0; i &lt; themes.Count; i++)
          {
  
              JsonObject section = themes[i].GetObject();
  
          }
  
      }
  </code></pre>
  
  <p>So this works, but if i use the same parse method and use this code to get file from local file in my app if failswith the error "WinRT information: WEB_E_INVALID_JSON_STRING" . </p>
  
  <pre><code>FileSync.Read&lt;string&gt;(installedLocation, "config.json",
             (fileSize, reader) =&gt;
                 reader.ReadString(fileSize),
                 responseText =&gt;
                 {
                     ParseJson(responseText);
  
                 })
  
     public static class FileSync
  {
      public static async void Read&lt;TDocument&gt;(StorageFolder folder, string fileName,
          Func&lt;uint, DataReader, TDocument&gt; reader, Action&lt;TDocument&gt; completion = null)
      {
  
  
          StorageFile file;
          IRandomAccessStream stream;
          IInputStream inputStream;
          DataReader dr;
  
          file = await folder.GetFileAsync(fileName);
  
          stream = await file.OpenAsync(FileAccessMode.Read);
          inputStream = stream.GetInputStreamAt(0);
  
          uint fileSize = (uint)stream.Size;
  
          dr = new DataReader(inputStream);
          await dr.LoadAsync(fileSize);
  
          Task&lt;TDocument&gt; task = new Task&lt;TDocument&gt;(() =&gt; reader(fileSize, dr));
          task.Start();
          TDocument doc = await task;
  
          if (completion != null)
          {
              completion(doc);
          }
      }
  
      public static async void Write&lt;TDocument&gt;(StorageFolder folder, string fileName,
  CreationCollisionOption collisionOption, TDocument doc,
  Action&lt;DataWriter, TDocument&gt; writer, Action&lt;bool&gt; complete = null)
      {
          StorageFile creator;
          IRandomAccessStream stream;
          IOutputStream outputStream;
          DataWriter dw;
  
          creator = await folder.CreateFileAsync(fileName, collisionOption);
  
          stream = await creator.OpenAsync(FileAccessMode.ReadWrite);
          outputStream = stream.GetOutputStreamAt(0);
  
          dw = new DataWriter(outputStream);
  
          Task task = new Task(() =&gt; writer(dw, doc));
          task.Start();
          await task;
  
          await dw.StoreAsync();
          bool success = await outputStream.FlushAsync();
          if (complete != null)
          {
              complete(success);
          }
      }
  }
  </code></pre>
  
  <p>Anyone can help me out figure if this a bug from the preview version or is something that i m missing?!</p>
  
  <p>Thanks in advance</p>