java
コマンド ラインツールで期待どおりに正しく動作するコードがあります。
私がEclipseに追加したときの同じコードは、いくつかのエラーをスローします:
Exception in thread "main" java.lang.Error: Unresolved compilation problem:
Cannot cast from Object to long
ライン上:
long statusId = (long)json.get("status_id");
ただしjavac
、java
コマンドを使用すると、プログラムを実行して出力が成功します。
WTH 日食はこのように動作しています! そして、これは私の最初のEclipseプログラムです。親切に助けてください。
編集:
コード :
public InitOrderResponse connect()
{
Authentication auth = new Authentication();
String response = auth.httpBasicAuth(this.constructUrl(),this.key);
JSONObject json = (JSONObject) JSONValue.parse(response);
String merchantId = (String)json.get("merchant_id");
long statusId = (long)json.get("status_id");
String status = (String)json.get("status");
String orderId = (String)json.get("order_id");
initOrderResponse = new InitOrderResponse();
initOrderResponse.setStatus(status);
initOrderResponse.setOrderId(orderId);
initOrderResponse.setStatusId(statusId);
initOrderResponse.setMerchantId(merchantId);
return initOrderResponse;
}