预期begin_object但是第1行第1列的字符串

时间:2015-09-30 13:06:36

标签: java android

我正在开发一个Android应用程序,在那个,我有一个任务来更新配置文件图像,当我尝试更新图像我收到该错误,我不知道是什么是该错误的根本原因请帮助我如何解决这个问题。

我的日志在

之下
Caused by: com.google.gson.JsonSyntaxException: java.lang.IllegalStateException: Expected BEGIN_OBJECT but was STRING at line 1 column 1 path $
            at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$Adapter.read(ReflectiveTypeAdapterFactory.java:200)
            at com.google.gson.Gson.fromJson(Gson.java:810)
            at com.google.gson.Gson.fromJson(Gson.java:775)
            at com.google.gson.Gson.fromJson(Gson.java:724)
            at com.ringee.app.ImageUploadActivity$5$2.doInBackground(ImageUploadActivity.java:215)
            at com.ringee.app.ImageUploadActivity$5$2.doInBackground(ImageUploadActivity.java:206)
            at android.os.AsyncTask$2.call(AsyncTask.java:288)
            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:841)
     Caused by: java.lang.IllegalStateException: Expected BEGIN_OBJECT but was STRING at line 1 column 1 path $
            at com.google.gson.stream.JsonReader.beginObject(JsonReader.java:387)
            at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$Adapter.read(ReflectiveTypeAdapterFactory.java:189)
            at com.google.gson.Gson.fromJson(Gson.java:810)
            at com.google.gson.Gson.fromJson(Gson.java:775)
            at com.google.gson.Gson.fromJson(Gson.java:724)
            at com.ringee.app.ImageUploadActivity$5$2.doInBackground(ImageUploadActivity.java:215)
            at com.ringee.app.ImageUploadActivity$5$2.doInBackground(ImageUploadActivity.java:206)
            at android.os.AsyncTask$2.call(AsyncTask.java:288)
            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:841)

我的代码在

下面
{
                    new AsyncTask<Void, Void, Bitmap>() {
                        @Override
                        protected Bitmap doInBackground(Void... arg0) {
                            MediaMO mediaMO1 = new MediaMO();
                            mediaMO1.setRingeeUserId(userMO.getRingeeUserId());
                            mediaMO1.setIsType(Constants.IS_TYPE_PROFILE_IMAGE);
                            String mediaMo = mediaDelegates.updateFileToServer(mediaMO1, context, imgFile);
                            // String mediaMo = mediaDelegates.updateFileToServer(mediaMO, context, imgFile);
                            if (!mediaMo.equals("null")) {
                            //I am getting that error here
                                mediaMO = gson.fromJson(mediaMo, new TypeToken<MediaMO>() {
                                }.getType());

                                try {
                                    URL url = new URL(mediaMO.getFileSrcLink());
                                    HttpURLConnection connection = (HttpURLConnection) url.openConnection();
                                    connection.setDoInput(true);
                                    connection.connect();
                                    InputStream input = connection.getInputStream();
                                    return BitmapFactory.decodeStream(input);
                                } catch (IOException e) {
                                    Log.i(Constants.TAG, e.toString());
                                }
                            }
                            Bitmap largeIcon = BitmapFactory.decodeResource(getResources(), R.drawable.ic_action_user);
                            return largeIcon;
                        }

                        @Override
                        protected void onPostExecute(Bitmap myBitmap) {
                            prgDialog.cancel();
                            imageView.setImageBitmap(myBitmap);
                        }
                    }.execute(null, null, null);
                }

我的json是

    {"UserId":1,"mediaId":0,"isType":1,"isDelete":0}

0 个答案:

没有答案