Facebook JSon データの解析に問題があります。私のデータ形式はこのようなものです。これに多くの時間を費やしましたが、値が得られませんでした。この問題の解決方法を教えてください。貴重な回答をお待ちしております。
ジェイソン
{
"id": "",
"name": "",
"first_name": "",
"middle_name": "",
"last_name": "",
"link": "",
"username": "",
"birthday": "",
"location": {
"id": "",
"name": ", "
}
Actullay を 更新 します。 jSonObject それは真の偽物を与えます(理由と方法を取得していません)
httpConnection のコード
public class JsonParsing {
static InputStream is = null;
static JSONObject jObj = null;
static String json = "";
// constructor
public JsonParsing() {
}
public JSONObject getJSONFromUrl(String url) {
// Making HTTP request
try {
// defaultHttpClient
DefaultHttpClient httpClient = new DefaultHttpClient();
HttpPost httpPost = new HttpPost(url);
HttpResponse httpResponse = httpClient.execute(httpPost);
HttpEntity httpEntity = httpResponse.getEntity();
is = httpEntity.getContent();
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
} catch (ClientProtocolException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
StringBuilder buffer = new StringBuilder();
BufferedReader reader = new BufferedReader(new InputStreamReader(
in, HTTP.UTF_8));
String line = null;
try {
while ((line = reader.readLine()) != null) {
buffer.append(line);
}
json = buffer.toString();
} finally {
in.close();
reader.close();
}
// try parse the string to a JSON object
try {
jObj = new JSONObject(json);
} catch (JSONException e) {
Log.e("JSON Parser", "Error parsing data " + e.toString());
}
// return JSON String
return jObj;
}
}
その後、これをパーサーに送信し、次のエラーを取得します
ログキャット
E/JSON Parser( 5660): Error parsing data org.json.JSONException: Value true of type java.lang.Boolean cannot be converted to JSONObject