Ash*_*i K 2 android android-volley
我正在使用Android Volley进行网络通话.通常我使用JSONRequest接收json数据,然后使用GSON将它们转换为对象.
new Response.Listener<JSONObject>() {
@Override
public void onResponse(JSONObject response) {
///Convert response.toString() to POJO using GSON
}
};
Run Code Online (Sandbox Code Playgroud)
如果我使用普通字符串请求然后使用GSON将字符串转换为对象,那么它会比JSONRequest更快吗?
new Response.Listener<String>() {
@Override
public void onResponse(String response) {
///Convert response to POJO using GSON
}
};
Run Code Online (Sandbox Code Playgroud)
谢谢
使用它会更有效,StringRequest因为返回的原始数据是String格式,JSONRequest将String转换JSONObject为您的案例不需要的.
实际上你可以实现自己的GSONRequest,你可以谷歌GSON volley许多参考.
这是一个例子: 使用齐射发出GSON请求
| 归档时间: |
|
| 查看次数: |
3120 次 |
| 最近记录: |