android webservice 传递对象,将arraylist bean从android传递给webservice php

我是带有网络服务的android的新手

我试图将arraylist从android传递到webservice php服务器

这是我的bean代码:

public class ExpressionBean {

public static final String EXPRESSION_ID = "expressionID";

public static final String EXPRESSION_TEXT = "expressionText";

public static final String ANS_TEXT1 = "ansText1";

public static final String ANS_TEXT2 = "ansText2";

public static final String ASSESSEE_ANSWER = "assesseeAnswer";

private String expressionID;

private String expressionText;

private String ansText1;

private String ansText2;

private String assesseeAnswer;

public String getExpressionID() {

return expressionID;

}

public void setExpressionID(String expressionID) {

this.expressionID = expressionID;

}

public String getExpressionText() {

return expressionText;

}

public void setExpressionText(String expressionText) {

this.expressionText = expressionText;

}

public String getAnsText1() {

return ansText1;

}

public void setAnsText1(String ansText1) {

this.ansText1 = ansText1;

}

public String getAnsText2() {

return ansText2;

}

public void setAnsText2(String ansText2) {

this.ansText2 = ansText2;

}

public String getAssesseeAnswer() {

return assesseeAnswer;

}

public void setAssesseeAnswer(String assesseeAnswer) {

this.assesseeAnswer = assesseeAnswer;

}

}

这是异步任务的doInBackround:

protected Boolean doInBackground(Void... params) {

// TODO: attempt authentication against a network service.

boolean result = false;

// test = new TestBean();

// int resultTest = 0;

UserFunctions userFunction = new UserFunctions();

Log.d(TAG, "UID : " + mEmail);

// Log.d(TAG, "resultTest : " + resultTest);

JSONObject jsonTest = userFunction.storeTest(mEmail);

Log.d(TAG, "After JSON TEST ");

try {

if (jsonTest.getString(KEY_SUCCESS) != null) {

String res = jsonTest.getString(KEY_SUCCESS);

JSONObject testData = jsonTest.getJSONObject(TAG_TEST);

test = new TestBean();

test.setTestid(testData.getInt(TAG_TEST_ID));

test.setUid(testData.getInt(TAG_UID));

JSONArray list = new JSONArray();

String list2;

for (int position = 0; position < expressionList.size(); position++) {

Gson gson = new Gson();

list.put(gson.toJson(expressionList.get(position)));

}

Log.d(TAG, "JSONArray list coy : " + list);

UserFunctions uf = new UserFunctions();

JSONObject jsonHistoryList = new JSONObject();

jsonHistoryList = uf.storeHistoryList(list.toString());

if (Integer.parseInt(res) == 1) {

result = true;

finish();

} else {

result = false;

}

}

} catch (JSONException e) {

e.printStackTrace();

return false;

}

// TODO: register the new account here.

return result;

}

这里是storeHistoryList方法:

public JSONObject storeHistoryList(String list) {

// Building Parameters

List params = new ArrayList();

params.add(new BasicNameValuePair("tag", storeHistory_tag));

params.add(new BasicNameValuePair("list", list));

JSONObject json = jsonParser.getJSONFromUrl(URL, params);

return json;

}

我想将列表传递给Web服务

list是一个arraylist ExpressionBean

我使用gson转换bean到json

但是当我执行时,日志说

“解析数据时出错…

jsonarray无法转换为jsonobject

我必须做什么?

谢谢

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值