@Deprecated public static JSONObject parseJson(String response) throws JSONException, FacebookError {
  if (response.equals("false")) {
    throw new FacebookError("request failed");
  }
  if (response.equals("true")) {
    response="{value : true}";
  }
  JSONObject json=new JSONObject(response);
  if (json.has("error")) {
    JSONObject error=json.getJSONObject("error");
    throw new FacebookError(error.getString("message"),error.getString("type"),0);
  }
  if (json.has("error_code") && json.has("error_msg")) {
    throw new FacebookError(json.getString("error_msg"),"",Integer.parseInt(json.getString("error_code")));
  }
  if (json.has("error_code")) {
    throw new FacebookError("request failed","",Integer.parseInt(json.getString("error_code")));
  }
  if (json.has("error_msg")) {
    throw new FacebookError(json.getString("error_msg"));
  }
  if (json.has("error_reason")) {
    throw new FacebookError(json.getString("error_reason"));
  }
  return json;
}

@ Deprecated public static JSONObject parseJson ( String response ) throws JSONException , FacebookError { if ( response . equals ( "false" ) ) { throw new FacebookError ( "request failed" ) ; } if ( response . equals ( "true" ) ) { response = "{value : true}" ; } JSONObject json = new JSONObject ( response ) ; if ( json . has ( "error" ) ) { JSONObject error = json . getJSONObject ( "error" ) ; throw new FacebookError ( error . getString ( "message" ) , error . getString ( "type" ) , 0 ) ; } if ( json . has ( "error_code" ) && json . has ( "error_msg" ) ) { throw new FacebookError ( json . getString ( "error_msg" ) , "" , Integer . parseInt ( json . getString ( "error_code" ) ) ) ; } if ( json . has ( "error_code" ) ) { throw new FacebookError ( "request failed" , "" , Integer . parseInt ( json . getString ( "error_code" ) ) ) ; } if ( json . has ( "error_msg" ) ) { throw new FacebookError ( json . getString ( "error_msg" ) ) ; } if ( json . has ( "error_reason" ) ) { throw new FacebookError ( json . getString ( "error_reason" ) ) ; } return json ; }
parse a server response into a json object . this is a basic implementation using org . json . jsonobject representation . more sophisticated applications may wish to do their own parsing . the parsed json is checked for a variety of error fields and a facebookexception is thrown if an error condition is set , populated with the error message and error type or code if available .
