错误提示:
通用域名格式。谷歌。格森。JsonSyntaxException:java。lang.IllegalStateException:应为BEGIN\u对象,但在改装中的第1行第2列路径$处为BEGIN\u数组
这是我的职责:
public interface I_GetStockTransferForLocation {
@FormUrlEncoded
@POST("/DataAccessService.svc/GetStockTransferForLocation")
void getStockFrLocation(@Field("COMPANY_ID")
String companyId ,@Field("LOCATION_ID")
String locationId ,@Field("TRANSACTION_DATE")
String transactionDate ,
Callback<RFResp_GetStockTransferFrLocatn> callback); }
public class RFResp_GetStockTransferFrLocatn {
@SerializedName("StockTransferList") private List<StockTransferList>
stockTransferList = new ArrayList<StockTransferList>();
@SerializedName("Transfer_Date")
private String transferDate; }
private void getStockTransferFrLocation() {
RestAdapter adapterGetStockTransfer = new RestAdapter.Builder()
.setEndpoint(ROOT_URL) //Setting the Root URL
.build(); //Finally building the adapter
//Creating object for our interface
I_GetStockTransferForLocation api = adapterGetStockTransfer.create(I_GetStockTransferForLocation.class);
api.getStockFrLocation(strCompanyId, strLocationId, strST_date, new Callback<RFResp_GetStockTransferFrLocatn>() {
@Override
public void success(RFResp_GetStockTransferFrLocatn rfResp_getStockTransferFrLocatn, retrofit.client.Response response) {
List<StockTransferList> stockTransferLists = rfResp_getStockTransferFrLocatn.getStockTransferList();
db = new Database(context);
stckTransferFk = db.getLastStock();
if (stckTransferFk == 0){
stckTransferFk = 1;
}
else{
stckTransferFk = stckTransferFk + 1;
}
if(stockTransferLists.size()>0) {
db = new Database(context);
db.clearStockTransferData();
db.createStockTransfer(rfResp_getStockTransferFrLocatn.getTransferDate(), stockTransferLists,stckTransferFk);
Intent intent = new Intent("com.dj.prachi");
intent.putExtra("customers_count",db.getCustomerCount()+"");
intent.putExtra("products_count",db.getProductCount()+"");
LocalBroadcastManager.getInstance(getApplicationContext()).sendBroadcast(intent);
Log.e("Prachi","Stock Transfer array"+stockTransferLists.size());
}
}
@Override
public void failure(RetrofitError error) {
Log.e("Prachi","Stock Transfr Error"+error.getMessage());
}
});
}
我的回答是
[
{
"StockTransferList": [
{
"CLOSING_STOCK_QTY": "0.00",
"COMPANY_ID": "7",
"LOCATION_ID": "1",
"OPENING_STOCK_QTY": "0.00",
"STOCKITEM_ID": "12107",
"TRANSACION_ID": "0",
"TRANSFER_IN_QTY": "0.00"
},
{
"CLOSING_STOCK_QTY": "0.00",
"COMPANY_ID": "7",
"LOCATION_ID": "1",
"OPENING_STOCK_QTY": "0.00",
"STOCKITEM_ID": "12108",
"TRANSACION_ID": "0",
"TRANSFER_IN_QTY": "0.00"
},
{
"CLOSING_STOCK_QTY": "30.00",
"COMPANY_ID": "7",
"LOCATION_ID": "1",
"OPENING_STOCK_QTY": "0.00",
"STOCKITEM_ID": "12109",
"TRANSACION_ID": "0",
"TRANSFER_IN_QTY": "30.00"
},
{
"CLOSING_STOCK_QTY": "0.00",
"COMPANY_ID": "7",
"LOCATION_ID": "1",
"OPENING_STOCK_QTY": "0.00",
"STOCKITEM_ID": "12110",
"TRANSACION_ID": "0",
"TRANSFER_IN_QTY": "0.00"
},
{
"CLOSING_STOCK_QTY": "0.00",
"COMPANY_ID": "7",
"LOCATION_ID": "1",
"OPENING_STOCK_QTY": "0.00",
"STOCKITEM_ID": "12111",
"TRANSACION_ID": "0",
"TRANSFER_IN_QTY": "0.00"
},
{
"CLOSING_STOCK_QTY": "30.00",
"COMPANY_ID": "7",
"LOCATION_ID": "1",
"OPENING_STOCK_QTY": "0.00",
"STOCKITEM_ID": "12112",
"TRANSACION_ID": "0",
"TRANSFER_IN_QTY": "30.00"
},
{
"CLOSING_STOCK_QTY": "0.00",
"COMPANY_ID": "7",
"LOCATION_ID": "1",
"OPENING_STOCK_QTY": "0.00",
"STOCKITEM_ID": "12113",
"TRANSACION_ID": "0",
"TRANSFER_IN_QTY": "0.00"
},
{
"CLOSING_STOCK_QTY": "0.00",
"COMPANY_ID": "7",
"LOCATION_ID": "1",
"OPENING_STOCK_QTY": "0.00",
"STOCKITEM_ID": "12114",
"TRANSACION_ID": "0",
"TRANSFER_IN_QTY": "0.00"
},
{
"CLOSING_STOCK_QTY": "0.00",
"COMPANY_ID": "7",
"LOCATION_ID": "1",
"OPENING_STOCK_QTY": "0.00",
"STOCKITEM_ID": "12115",
"TRANSACION_ID": "0",
"TRANSFER_IN_QTY": "0.00"
},
{
"CLOSING_STOCK_QTY": "0.00",
"COMPANY_ID": "7",
"LOCATION_ID": "1",
"OPENING_STOCK_QTY": "0.00",
"STOCKITEM_ID": "12116",
"TRANSACION_ID": "0",
"TRANSFER_IN_QTY": "0.00"
},
{
"CLOSING_STOCK_QTY": "0.00",
"COMPANY_ID": "7",
"LOCATION_ID": "1",
"OPENING_STOCK_QTY": "0.00",
"STOCKITEM_ID": "12117",
"TRANSACION_ID": "0",
"TRANSFER_IN_QTY": "0.00"
},
{
"CLOSING_STOCK_QTY": "0.00",
"COMPANY_ID": "7",
"LOCATION_ID": "1",
"OPENING_STOCK_QTY": "0.00",
"STOCKITEM_ID": "12118",
"TRANSACION_ID": "0",
"TRANSFER_IN_QTY": "0.00"
},
{
"CLOSING_STOCK_QTY": "0.00",
"COMPANY_ID": "7",
"LOCATION_ID": "1",
"OPENING_STOCK_QTY": "0.00",
"STOCKITEM_ID": "12119",
"TRANSACION_ID": "0",
"TRANSFER_IN_QTY": "0.00"
},
{
"CLOSING_STOCK_QTY": "0.00",
"COMPANY_ID": "7",
"LOCATION_ID": "1",
"OPENING_STOCK_QTY": "0.00",
"STOCKITEM_ID": "12120",
"TRANSACION_ID": "0",
"TRANSFER_IN_QTY": "0.00"
}
],
"Transfer_Date": "25/06/2016"
}
]
如下创建父pojo并在该pojo中获取响应:
public class ParentPojo extends List<RFResp_GetStockTransferFrLocatn > {
}
您的方法如下所示:
private void getStockTransferFrLocation() {
RestAdapter adapterGetStockTransfer = new RestAdapter.Builder()
.setEndpoint(ROOT_URL) //Setting the Root URL
.build(); //Finally building the adapter
//Creating object for our interface
I_GetStockTransferForLocation api = adapterGetStockTransfer.create(I_GetStockTransferForLocation.class);
api.getStockFrLocation(strCompanyId, strLocationId, strST_date, new Callback<RFResp_GetStockTransferFrLocatn>() {
@Override
public void success(ParentPojo rfResp_getStockTransferFrLocatn, retrofit.client.Response response) {
for(int i=0;i<rfResp_getStockTransferFrLocatn.length;i++){
List<RFResp_GetStockTransferFrLocatn > stockTransferLists= rfResp_getStockTransferFrLocatn.get(i).getStockTransferList();
db = new Database(context);
stckTransferFk = db.getLastStock();
if (stckTransferFk == 0){
stckTransferFk = 1;
}
else{
stckTransferFk = stckTransferFk + 1;
}
if(stockTransferLists.size()>0) {
db = new Database(context);
db.clearStockTransferData();
db.createStockTransfer(rfResp_getStockTransferFrLocatn.getTransferDate(), stockTransferLists,stckTransferFk);
Intent intent = new Intent("com.dj.prachi");
intent.putExtra("customers_count",db.getCustomerCount()+"");
intent.putExtra("products_count",db.getProductCount()+"");
LocalBroadcastManager.getInstance(getApplicationContext()).sendBroadcast(intent);
Log.e("Prachi","Stock Transfer array"+stockTransferLists.size());
}
}
}
@Override
public void failure(RetrofitError error) {
Log.e("Prachi","Stock Transfr Error"+error.getMessage());
}
});
}
问题似乎与您如何设置调用I\u GetStockTransferForLocation有关,从代码来看,它似乎期望得到一个对象RFResp\u GetStockTransferFrLocatn,但实际上从您发布的json来看,您应该得到这些对象的列表。
您只需更改I\u GetStockTransferForLocation的定义,即可使用列表
您还需要将回调从void success(RFResp\u GetStockTransferFrLocatn RFResp\u GetStockTransferFrLocatn,reformation.client.Response)
调整为void success(列表
如果你看一下你得到的错误,应该是BEGIN\u OBJECT,但它是BEGIN\u ARRAY,这是gson的意思,意思是他需要一个带有对象的json,但实际上它得到的是一个对象列表。在您的情况下,这就是界面的工作方式:
public interface I_GetStockTransferForLocation {
@FormUrlEncoded
@POST("/DataAccessService.svc/GetStockTransferForLocation")
void getStockFrLocation(@Field("COMPANY_ID") String companyId,
@Field("LOCATION_ID") String locationId,
@Field("TRANSACTION_DATE") String transactionDate,
Callback<List<RFResp_GetStockTransferFrLocatn>> callback); }
如果你需要更多帮助,请告诉我。
然后模型确定输入形状为28,28,1,因为60k是样本。 我得到错误:值错误:检查输入时的错误:预期conv2d_19_input有4个维度,但得到了具有形状(60000, 28, 28)的数组 就像每次我试图理解输入形状时一样,我会更加困惑。就像我现在对conv2d和dense的输入形状感到困惑一样。无论如何,为什么这是错误的?
我是新来的。当我映射响应体它给错误。 应为“Map”类型的值
我已经实现了这些代码; 我正在实现数据绑定,我已经实现了所有用于数据绑定的东西,我已经在布局中初始化了变量,但他们给出了错误:无法找到符号类ImplementAndroidArchitecture
我在Android中通过改装调用RestAPI,每一个其他请求工作正常,并给我有效的响应,但此请求加载有点慢,需要时间加载,但当我得到响应其代码为200,但响应体为空等了一段时间后。 这是OkkHttp客户端,它的加载也扩展到加载json,因为它很慢。 在这个方法中调用API 这是我的反应体。。。。有人能帮我解释一下为什么我在这里得到了空身体吗。这是回应 这是Mode类产品。 }
我使用超文本传输协议:^0.13.3,这是我的简单代码,当我运行此代码时,我得到了错误:"期望类型'Map的值
在Flatter中实现facebook登录后,我出现了这些错误。我的代码无法执行 e:C:/Users/HP/。gradle/caches/transforms-2/files-2.1/0c02c09b68f8e9b24bbbea025e769c0c/jetified-facebook-core-12.2.0-api。罐子/META-INF/facebook-core_发布。kotlin_模块:模