我试图形成如下所示的请求参数,
{"keywords":"Fufh",
"tootiText":"",
"email":"davmooray@gmail.com",
"tweetDate":"2016-05-07T13:04:03.019+0530",
"isFavorite":"false",
"cultureName":"en-GB",
"longitude":"79.819694",
"rating":"0",
"latitude":"11.9528747",
"weatherType":"0",
"thumbnailColor":"#0076BF",
"measureTooteets":"[{"value":"3","startDate":"1970-01-01T00:00:00","measureTypeId":1,"endDate":"1970-01-01T00:00:00","isTimeSet":true},{"value":"3","startDate":"1970-01-01T00:00:00","measureTypeId":26,"endDate":"1970-01-01T00:00:00","isTimeSet":true},{"value":"4545","startDate":"1970-01-01T00:00:00","measureTypeId":26,"endDate":"1970-01-01T00:00:00","isTimeSet":true}]"}
使用以下方法
private Request createMeasureTooteet(Tooteet tooteet) {
Map<String, String> params = getParamsForMeasure(tooteet);
Log.d("ss","Create Measure param_____________"+params.toString());
HttpEntity entity = ApiUtils.getEntity(params);
try {
Log.d("ss","Create Measure entity 1_____________"+EntityUtilsHC4.toString(entity));
} catch (IOException e) {
e.printStackTrace();
}
((StringEntity) entity).setContentType(HeaderUtils.CONTENT_TYPE_JSON);
try {
Log.d("ss","Create Measure entity 2_____________"+EntityUtilsHC4.toString(entity));
} catch (IOException e) {
e.printStackTrace();
}
return new Request(TooteetType.NOTE, entity, tooteet);
}
我在下面点击日志,
Create Measure param_____________{tootiText=, keywords=Gdfyvj, email=davmooray@gmail.com, tweetDate=2016-05-07T13:55:16.635+0530, isFavorite=false, longitude=79.8200781, cultureName=en-GB, weatherType=0, latitude=11.9534879, rating=0, measureTooteets=[{"value":"5","startDate":"1970-01-01T00:00:00","measureTypeId":1,"endDate":"1970-01-01T00:00:00","isTimeSet":true},{"value":"3","startDate":"1970-01-01T00:00:00","measureTypeId":26,"endDate":"1970-01-01T00:00:00","isTimeSet":true},{"value":"9","startDate":"1970-01-01T00:00:00","measureTypeId":18,"endDate":"1970-01-01T00:00:00","isTimeSet":true}], thumbnailColor=#0076BF}
Create Measure entity 1_____________{"keywords":"Gdfyvj","tootiText":"","email":"davmooray@gmail.com","tweetDate":"2016-05-07T13:55:16.635+0530","isFavorite":"false","cultureName":"en-GB","longitude":"79.8200781","rating":"0","latitude":"11.9534879","weatherType":"0","thumbnailColor":"#0076BF","measureTooteets":"[{\"value\":\"5\",\"startDate\":\"1970-01-01T00:00:00\",\"measureTypeId\":1,\"endDate\":\"1970-01-01T00:00:00\",\"isTimeSet\":true},{\"value\":\"3\",\"startDate\":\"1970-01-01T00:00:00\",\"measureTypeId\":26,\"endDate\":\"1970-01-01T00:00:00\",\"isTimeSet\":true},{\"value\":\"9\",\"startDate\":\"1970-01-01T00:00:00\",\"measureTypeId\":18,\"endDate\":\"1970-01-01T00:00:00\",\"isTimeSet\":true}]"}
Create Measure entity 2_____________{"keywords":"Gdfyvj","tootiText":"","email":"davmooray@gmail.com","tweetDate":"2016-05-07T13:55:16.635+0530","isFavorite":"false","cultureName":"en-GB","longitude":"79.8200781","rating":"0","latitude":"11.9534879","weatherType":"0","thumbnailColor":"#0076BF","measureTooteets":"[{\"value\":\"5\",\"startDate\":\"1970-01-01T00:00:00\",\"measureTypeId\":1,\"endDate\":\"1970-01-01T00:00:00\",\"isTimeSet\":true},{\"value\":\"3\",\"startDate\":\"1970-01-01T00:00:00\",\"measureTypeId\":26,\"endDate\":\"1970-01-01T00:00:00\",\"isTimeSet\":true},{\"value\":\"9\",\"startDate\":\"1970-01-01T00:00:00\",\"measureTypeId\":18,\"endDate\":\"1970-01-01T00:00:00\",\"isTimeSet\":true}]"}
将params转换为实体斜杠后,如上所述添加到我的请求中。但我的请求必须发送如下
{"keywords":"Fufh",
"tootiText":"",
"email":"davmooray@gmail.com",
"tweetDate":"2016-05-07T13:04:03.019+0530",
"isFavorite":"false",
"cultureName":"en-GB",
"longitude":"79.819694",
"rating":"0",
"latitude":"11.9528747",
"weatherType":"0",
"thumbnailColor":"#0076BF",
"measureTooteets":"[{"value":"3","startDate":"1970-01-01T00:00:00","measureTypeId":1,"endDate":"1970-01-01T00:00:00","isTimeSet":true},{"value":"3","startDate":"1970-01-01T00:00:00","measureTypeId":26,"endDate":"1970-01-01T00:00:00","isTimeSet":true},{"value":"4545","startDate":"1970-01-01T00:00:00","measureTypeId":26,"endDate":"1970-01-01T00:00:00","isTimeSet":true}]"}
如何从实体中删除斜杠?请建议我任何想法..