title: Unity: Error Parsing JSON from Remote Source
body: <p>In Unity 5.4, I have a JSON file I can successfully parse via <em>JsonUtility.FromJson</em> when I fetch it locally from StreamingAssets, but fetching that same same file via <em>WWW</em> throws an error (<em>ArgumentException: JSON parse error: Invalid value</em>.) when I fetch it from a remote server.</p>
  
  <p>I can output both the local and remote (<em>jsonString</em>) files just prior to parsing by <em>JsonUtility</em>, and they are identical (I've even validated each in a JSON validator.)</p>
  
  <p>Here's the code I'm using to retrieve and parse the remote JSON:</p>
  
  <pre><code>    void Prime(){
      string url = "https:content_url.json";
      WWW www = new WWW(url);
      StartCoroutine(WaitForContentJSON(www));
  }
  
  IEnumerator WaitForContentJSON(WWW contentData)
  {
      yield return contentData;
  
      // check for errors
      if (contentData.error == null)
      {
          ParseJSON(contentData.text);
  
      } else {
          Debug.Log("WWW Error: "+ contentData.error);
      }    
  }
  
  void ParseJSON(string jsonString){
      var ac = JsonUtility.FromJson&lt;ArticlesCollection&gt;(jsonString);
  }
  </code></pre>
  
  <p>The error is thrown inside <em>ParseJSON</em> when invoking <em>JsonUtility.FromJson</em></p>
  
  <p>Any help much appreciated.</p>
  
  <h3>EDIT: Adding JSON per @Programmer's request</h3>
  
  <p>JSON returned from local file via <em>File.ReadAllText</em>:</p>
  
  <pre><code>{
    "articles": [ {
      "articleID": "1",
      "title": "Life &amp; Death at the Mexican Border",
      "byline": "Part 1 of Life and Death...",
      "longDescription": "Part 1 of Life and Death...",
      "imageURL": "http://foo.jpg",
      "videoURL": "http://foot.mp4",
      "sceneAssetBundle": "scene_bundle_1",
      "sceneName": "scene_1",
      "featured": true,
          "duration": "7:12",
          "videoSize": "625"
    }, {
      "articleID": "2",
      "title": "Lake Mead",
      "byline": "The shrinking water....",
      "longDescription": "Welcome...",
      "imageURL": "http://vfoo.jpg",
      "videoURL": "http://food.mp4",
      "sceneAssetBundle": "scene_bundle_2",
      "sceneName": "scene_2",
      "featured": true,
          "duration": "1:45",
          "videoSize": "151"
    }, {
      "articleID": "3",
      "title": "Visi...",
      "byline": "Experience...",
      "longDescription": "Experience...",
      "imageURL": "http://foo.jpg",
      "videoURL": "http://foo.mp4",
      "sceneAssetBundle": "scene_bundle_2",
      "sceneName": "scene_2",
      "featured": false,
          "duration": "5:46",
          "videoSize": "478"
    } ]
  }
  </code></pre>
  
  <p>JSON returned from remote (S3):</p>
  
  <pre><code>{
    "articles": [ {
      "articleID": "1",
      "title": "Life &amp; Death at...",
      "byline": "Part 1 of...",
      "imageURL": "http:foo.jpg",
      "videoURL": "http://foo.mp4",
      "featured": true,
          "duration": "7:12",
          "videoSize": "625"
    }, {
      "articleID": "2",
      "title": "Lake Mead",
      "byline": "The...",
      "longDescription": "Welcome...",
      "imageURL": "http://foo.jpg",
      "videoURL": "http://foo.mp4",
      "featured": true,
          "duration": "1:45",
          "videoSize": "151"
    }, {
      "articleID": "3",
      "title": "Visit",
      "byline": "Experience...",
      "longDescription": "Experience the...",
      "imageURL": "http:foo.jpg",
      "videoURL": "http://foo.mp4",
      "featured": false,
          "duration": "5:46",
          "videoSize": "478"
    } ]
  }
  </code></pre>
  
  <p>Again, I've validated both of these JSON files in a validator, and again the <em>JsonUtility.FromJson</em> call works fine when passed the JSON fetched locally but errors when passed the JSON from the remote source fetched via <em>WWW</em></p>
  
  <p>And, per @dbc's request I'm posting the body of my <em>ArticlesCollection</em> and <em>Articles</em> wrapper classes into/against(?) which the JSON is parsed. But again, this works fine when fetching the JSON locally, so I don't suspect there's an issue in these files.</p>
  
  <p><em>ArticlesCollection</em>:</p>
  
  <pre><code>using UnityEngine;
  
  [System.Serializable]
  public class ArticlesCollection
  {
      public Article[] articles;
  }
  </code></pre>
  
  <p><em>Articles</em>:</p>
  
  <pre><code>using UnityEngine;
  
  [System.Serializable]
  public class Article
  {
      public string title;
      public int articleID;
      public string byline;
      public string longDescription;
      public string imageURL;
      public string experienceURL;
      public bool featured;
      public string duration;
      public string experienceSize;
  
      public string sceneAssetBundle;
      public string sceneName;
  }
  </code></pre>