我在json工作时遇到异常.我的JSONPresr类如下
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.UnsupportedEncodingException;
import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.client.ClientProtocolException;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.impl.client.DefaultHttpClient;
import org.json.JSONException;
import org.json.JSONObject;
import android.os.AsyncTask;
import android.util.Log;
public class JSONParser {
static InputStream is = null;
static JSONObject jObj = null;
static String json = "";
// constructor
public JSONParser() {
}
public JSONObject getJSONFromUrl(String url) {
// Making HTTP request
try {
// defaultHttpClient
DefaultHttpClient httpClient = new DefaultHttpClient();
HttpPost httpPost = new HttpPost(url);
HttpResponse httpResponse = …Run Code Online (Sandbox Code Playgroud) 我正在为Android构建一个RESTful客户端,我对Jackson有疑问.
我得到以下JSON响应:
{
"cars": [
{
"active": "true",
"carName": "××× ×'פ ס××××§×",
"categoryId": {
"licenseType": "××××××",
"licenseTypeId": "1"
},
"id": "1401268",
"insuranceDate": "2011-07-05T00:00:00+03:00",
"lessonLength": "45",
"licenseDate": "2011-07-05T00:00:00+03:00",
"price": "100",
"productionYear": "2009-07-05T00:00:00+03:00"
},
{
"active": "true",
"carName": "××©× ×××",
"categoryId": {
"licenseType": "×ש××ת",
"licenseTypeId": "4"
},
"id": "1589151",
"insuranceDate": "2011-04-13T00:00:00+03:00",
"lessonLength": "30",
"licenseDate": "2011-04-13T00:00:00+03:00",
"price": "120",
"productionYear": "2004-04-12T00:00:00+03:00"
},............. etc
Run Code Online (Sandbox Code Playgroud)
每个都是一个类似汽车的汽车:
public class Cars implements Serializable {
private static final long serialVersionUID = 1L;
private Integer id;
private String carName;
private …Run Code Online (Sandbox Code Playgroud)