需要一个字符串,但在第 1 行第 123 列路径 $.options 处是 BEGIN_OBJECT。在 easypost 装运中
Expected a string but was BEGIN_OBJECT at line 1 column 123 path $.options. in easypost shipment
当我使用
shipment.create(shipmentMap, EASYPOSTAPIKEY)
它抛出一个错误预期的字符串但是 BEGIN_OBJECT
在第 1 行第 123 列路径 $.options
.
下面是我的代码
Map<String, Object> parcelMap = new HashMap<String, Object>();
parcelMap.put("predefined_package", "FlatRateEnvelope");
parcelMap.put("weight", 10);
Parcel parcel = Parcel.create(parcelMap);
Map<String, Object> shipmentMap = new HashMap<String, Object>();
shipmentMap.put("to_address", toAddress);
shipmentMap.put("from_address", fromAddress);
shipmentMap.put("parcel", parcel);
Shipment shipment = Shipment.create(shipmentMap, EASYPOSTAPIKEY);
java.lang.IllegalStateException: Expected a string but was
BEGIN_OBJECT at line 1 column 123 path $.options.at
com.google.gson.stream.JsonReader.nextString(JsonReader.java:825)
~[gson-2.8.5.jar:na]
我不确定 Easy post API 但例外
options.at com.google.gson.stream.JsonReader.nextString(JsonReader.java:825) ~[gson-2.8.5.jar]
可以说跟GSON有关
根据我的理解,GSON 说它需要一个字符串,但有一个对象。
为此提到了这个 post。
GSON throwing "Expected BEGIN_OBJECT but was BEGIN_ARRAY"?
我会请你再看一遍文档,检查你错过了什么
更新最新版本的 easy post 客户端 API 应该可以解决这个问题。
当我使用
shipment.create(shipmentMap, EASYPOSTAPIKEY)
它抛出一个错误预期的字符串但是 BEGIN_OBJECT
在第 1 行第 123 列路径 $.options
.
下面是我的代码
Map<String, Object> parcelMap = new HashMap<String, Object>();
parcelMap.put("predefined_package", "FlatRateEnvelope");
parcelMap.put("weight", 10);
Parcel parcel = Parcel.create(parcelMap);
Map<String, Object> shipmentMap = new HashMap<String, Object>();
shipmentMap.put("to_address", toAddress);
shipmentMap.put("from_address", fromAddress);
shipmentMap.put("parcel", parcel);
Shipment shipment = Shipment.create(shipmentMap, EASYPOSTAPIKEY);
java.lang.IllegalStateException: Expected a string but was BEGIN_OBJECT at line 1 column 123 path $.options.at com.google.gson.stream.JsonReader.nextString(JsonReader.java:825) ~[gson-2.8.5.jar:na]
我不确定 Easy post API 但例外
options.at com.google.gson.stream.JsonReader.nextString(JsonReader.java:825) ~[gson-2.8.5.jar]
可以说跟GSON有关
根据我的理解,GSON 说它需要一个字符串,但有一个对象。
为此提到了这个 post。 GSON throwing "Expected BEGIN_OBJECT but was BEGIN_ARRAY"?
我会请你再看一遍文档,检查你错过了什么
更新最新版本的 easy post 客户端 API 应该可以解决这个问题。