Android JSON URL抓取

时间:2016-12-25 03:50:52

标签: android json

好吧,我正在尝试为我的Android设计团队创建一个应用程序,而且我遇到了一个我似乎无法弄清楚的障碍。

这是我的json文件,应用程序假设正在阅读。

 {
  "status": "ok",
  "posts": [
    {
      "id": 1,
      "type": "post",
      "url": "https://play.google.com/store/apps/dev?id=4712980303859595180",
      "status": "publish",
      "title": "Google Developer Page",
      "content": "<p>Here's a link to our Google Play Developer Page!</p>",
      "date": "December 24 2016",
      "attachments": [
        {
          "url": "http://technologx.com/android/ghostninja/header.png",
          "mime_type": "image/png"
        }
      ]
    }
  ]
}

这是logcat:

E/AndroidRuntime: FATAL EXCEPTION: AsyncTask #4
                  Process: com.technologx.firebirddesigns, PID: 32228
                  java.lang.RuntimeException: An error occured while executing doInBackground()
                      at android.os.AsyncTask$3.done(AsyncTask.java:304)
                      at java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:355)
                      at java.util.concurrent.FutureTask.setException(FutureTask.java:222)
                      at java.util.concurrent.FutureTask.run(FutureTask.java:242)
                      at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:231)
                      at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
                      at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
                      at java.lang.Thread.run(Thread.java:818)
                   Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'int java.lang.String.length()' on a null object reference
                      at org.json.JSONTokener.nextCleanInternal(JSONTokener.java:116)
                      at org.json.JSONTokener.nextValue(JSONTokener.java:94)
                      at org.json.JSONObject.<init>(JSONObject.java:156)
                      at org.json.JSONObject.<init>(JSONObject.java:173)
                      at com.technologx.firebirddesigns.Fragments.StoreFragment.getJSONFromUrl(StoreFragment.java:169)
                      at com.technologx.firebirddesigns.Fragments.StoreFragment$DownloadFilesTask.doInBackground(StoreFragment.java:128)
                      at com.technologx.firebirddesigns.Fragments.StoreFragment$DownloadFilesTask.doInBackground(StoreFragment.java:112)
                      at android.os.AsyncTask$2.call(AsyncTask.java:292)
                      at java.util.concurrent.FutureTask.run(FutureTask.java:237)
                      at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:231) 
                      at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112) 
                      at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587) 
                      at java.lang.Thread.run(Thread.java:818)

我已尝试使用json文件的几个不同主机,就像现在它在jsonblob.com上一样,它也不能使用该网站。当我打开应用程序或转到正在读取json文件的商店选项卡时​​,它会一直崩溃。

0 个答案:

没有答案