0

に私はAzureのモバイルアプリケーションを使用しています に、登録時にjava.lang.IllegalStateException:未JSONオブジェクト:[] Azureの操作

を私の新しいユーザーを挿入し、それはメッセージで例外がスローされます: java.lang.IllegalStateException:未JSONオブジェクト:[]

(Iユーザーのテーブルに何の実体を持っていない)

私のコード:ユーザーと製品

の間に3つの関係がある

public class User implements Serializable { 
@com.google.gson.annotations.SerializedName("id") 
private String id; 
@com.google.gson.annotations.SerializedName("name") 
private String name; 
@com.google.gson.annotations.SerializedName("live") 
private String live; 
@com.google.gson.annotations.SerializedName("age") 
private int age; 
@com.google.gson.annotations.SerializedName("password") 
private String password; 
@com.google.gson.annotations.SerializedName("account") 
private String account; 
@com.google.gson.annotations.SerializedName("phone") 
private String phone; 
@com.google.gson.annotations.SerializedName("email") 
private String email; 
@com.google.gson.annotations.SerializedName("imageUrl") 
private String imageUrl; 

@com.google.gson.annotations.SerializedName("productsHistoryRecord") 
private List<ProductImp> productsHistoryRecord; 
@com.google.gson.annotations.SerializedName("productsSales") 
private List<ProductImp> productsSales; 
@com.google.gson.annotations.SerializedName("productsInCart") 
private List<ProductImp> productsInCart; 
@com.google.gson.annotations.SerializedName("mails") 
private List<Mail> mails; 


public String getImageUrl() { 
    return imageUrl; 
} 

public void setImageUrl(String imageUrl) { 
    this.imageUrl = imageUrl; 
} 

public String getId() { 
    return id; 
} 

public String getName() { 
    return name; 
} 

public int getAge() { 
    return age; 
} 

public String getAccount() { 
    return account; 
} 

public String getLive() { 
    return live; 
} 

public String getPassword() { 
    return password; 
} 

public String getPhone() { 
    return phone; 
} 

public void setName(String name) { 
    this.name = name; 
} 

public void setAccount(String account) { 
    this.account = account; 
} 

public void setAge(int age) { 
    this.age = age; 
} 

public void setLive(String live) { 
    this.live = live; 
} 

public void setPassword(String password) { 
    this.password = password; 
} 

public void setPhone(String phone) { 
    this.phone = phone; 
} 

public void setId(String id) { 
    this.id = id; 
} 

public void setEmail(String email) { 
    this.email = email; 
} 

public String getEmail() { 
    return email; 
} 

public List<Mail> getMails() { 
    return mails; 
} 

public void setMails(List<Mail> mails) { 
    this.mails = mails; 
} 

public List<ProductImp> getProductsHistoryRecord() { 
    return productsHistoryRecord; 
} 

public void setProductsHistoryRecord(List<ProductImp> productsHistoryRecord) { 
    this.productsHistoryRecord = productsHistoryRecord; 
} 

public List<ProductImp> getProductsInCart() { 
    return productsInCart; 
} 

public void setProductsInCart(List<ProductImp> productsInCart) { 
    this.productsInCart = productsInCart; 
} 

public List<ProductImp> getProductsSales() { 
    return productsSales; 
} 

public void setProductsSales(List<ProductImp> productsSales) { 
    this.productsSales = productsSales; 
} 

@Override 
public String toString() { 
    return "user information :" + name + "," + age + "," + live + "," + phone + "," + account + "," + password 
     + "," + productsHistoryRecord + "," + productsInCart + "," + productsSales ; 
} 

}

私はすべてのデータベース属性の名前をチェックした

public static void registerUserToTheDataBase(final User user){ 
    AsyncTask<Void, Void, Void> asyncTask = new AsyncTask<Void, Void, Void>() { 
     @Override 
     protected Void doInBackground(Void... voids) { 
      try { 
       UserManager.user = mUserManager.insert(user).get(); 
      } catch (Exception e) { 
       e.printStackTrace(); 
      } 

      return null; 
     } 
    }; 
    AsyncTaskController.runAsyncTask(asyncTask); 
} 

は正しい

であり、これは私のUserオブジェクトであります

これは私がMobileServerCliをインスタンス化する方法ですENT

public static void initiate(Context context) throws MalformedURLException { 
    mClient = new MobileServiceClient(LINK,context).withFilter(new ProgressFilter()); 
    mClient.setAndroidHttpClientFactory(new OkHttpClientFactory() { 
     @Override 
     public OkHttpClient createOkHttpClient() { 
      OkHttpClient client = new OkHttpClient(); 
      client.setReadTimeout(20, TimeUnit.SECONDS); 
      client.setWriteTimeout(20, TimeUnit.SECONDS); 
      return client; 
     } 
    }); 
    initiateTables(); 
} 

public static void initiateTables(){ 
    mUserManager = mClient.getTable("User",User.class); 
    mProduct = mClient.getTable("Product",ProductImp.class); 
    mMail = mClient.getTable("Mail",Mail.class); 
    mLockerImp = mClient.getTable("Locker",LockerImp.class); 
    mCart = mClient.getTable("Cart",CartList.class); 
} 

は、ここで私はそれ以外の場合はエラーが発生します最初の単語 で大文字にすべての属性を変更し、ユーザーテーブル の私のバックエンドのデータベーススキーマです。

enter image description here

おかげでたくさん。

+1

ここに十分な情報がありません。ユーザーオブジェクトはどのように見えますか? mUserManagerの定義は何ですか?どのようにクライアントをインスタンス化していますか? –

+0

申し訳ありません私は記事で補足した。 –

+0

エラーメッセージを見て、空のJSON配列 '[]'をオブジェクトとして解析しようとします。 – Henry

答えて

2

urlを変更してください。httpからhttps

+0

はい!あなたは私の質問を解決しました!あなたは私の日を作った!私は 's'を添付して問題を解決しました!!!!!!!!!!!!!!!!!! –