java.lang.IllegalStateException:不是 JSON 对象:[] 在 Azure 操作中
java.lang.IllegalStateException: Not a JSON Object: [] on Azure operation
我正在使用 Azure 移动应用程序
在注册时插入我的新用户,
然后它抛出一个异常消息:
java.lang.IllegalStateException:不是 JSON 对象:[]
(我在用户table中没有实体)
我的代码:
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);
}
我已经检查了我所有的数据库属性的名称都是正确的
这是我的用户对象
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 ;
}
}
User和Product之间存在三种关系
这就是我实例化 MobileServerClient 的方式
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);
}
这是我的用户 table 的后端数据库架构
我在第一个单词中将所有属性更改为大写
否则会出错。
非常感谢。
尝试修改urlhttp
为https
.
我正在使用 Azure 移动应用程序 在注册时插入我的新用户,
然后它抛出一个异常消息: java.lang.IllegalStateException:不是 JSON 对象:[]
(我在用户table中没有实体)
我的代码:
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);
}
我已经检查了我所有的数据库属性的名称都是正确的
这是我的用户对象
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 ;
}
}
User和Product之间存在三种关系
这就是我实例化 MobileServerClient 的方式
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);
}
这是我的用户 table 的后端数据库架构 我在第一个单词中将所有属性更改为大写 否则会出错。
非常感谢。
尝试修改urlhttp
为https
.