我正在从api struct获取数据时出现了此错误。我查阅了许多网站,以供参考,但我没有得到适当的解决方案
public class ApiClient {
public static final String BASE_URL = "http://stock.adverscribe.in/api/controllers/";
private static Retrofit retrofit = null;
public
static Retrofit getClient() {
Gson gson = new GsonBuilder()
.setLenient()
.create();
if (retrofit == null) {
retrofit = new Retrofit.Builder()
.baseUrl(BASE_URL)
.addConverterFactory(GsonConverterFactory.create(gson))
.build();
}
return retrofit;
}
}
Api接口。JAVA
public interface ApiInterface {
@GET("getMenu")
Call<MenuResponse> getMenuResult();
}
主要活动。JAVA
public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
ApiInterface apiService = ApiClient.getClient().create(ApiInterface.class);
Call<MenuResponse> call = apiService.getMenuResult();
call.enqueue(new Callback<MenuResponse>() {
@Override
public void onResponse(Call<MenuResponse> call, Response<MenuResponse> response) {
int code = response.body().getCode();
Toast.makeText(MainActivity.this, "" + code, Toast.LENGTH_SHORT).show();
}
@Override
public void onFailure(Call<MenuResponse> call, Throwable t) {
Toast.makeText(MainActivity.this, "" + t.getMessage(), Toast.LENGTH_SHORT).show();
}
});
}
}
这是json数据
{
"code": 200,
"message": "SUCCESS",
"data": {
"menu": [
{
"division": {
"stock_division_id": "1",
"stock_division_name": "Men",
"stock_division_status": "1",
"created_date": "2018-01-12 11:59:00",
"updated_date": "2018-01-12 11:59:22"
},
"cat": [
{
"stock_category_id": "1",
"stock_division_id": "1",
"stock_category_name": "T-Shirts",
"stock_category_status": "1",
"created_date": "2018-01-12 12:00:14",
"updated_date": "2018-01-12 12:00:14"
}
]
},
{
"division": {
"stock_division_id": "2",
"stock_division_name": "Women",
"stock_division_status": "1",
"created_date": "2018-01-12 11:59:44",
"updated_date": "2018-01-12 11:59:44"
},
"cat": [
{
"stock_category_id": "2",
"stock_division_id": "2",
"stock_category_name": "T-Shirts",
"stock_category_status": "1",
"created_date": "2018-01-12 12:02:24",
"updated_date": "2018-01-12 12:02:24"
}
]
}
]
}
}
错误堆栈
01-23 18:34:14.219 13628-13628/? I/art: Late-enabling -Xcheck:jni
01-23 18:34:14.544 13628-13628/com.adverscribe.myapplication W/System: ClassLoader referenced unknown path: /data/app/com.adverscribe.myapplication-2/lib/arm
01-23 18:34:14.567 13628-13628/com.adverscribe.myapplication I/InstantRun: starting instant run server: is main process
01-23 18:34:14.687 13628-13628/com.adverscribe.myapplication W/art: Before Android 4.1, method android.graphics.PorterDuffColorFilter android.support.graphics.drawable.VectorDrawableCompat.updateTintFilter(android.graphics.PorterDuffColorFilter, android.content.res.ColorStateList, android.graphics.PorterDuff$Mode) would have incorrectly overridden the package-private method in android.graphics.drawable.Drawable
01-23 18:34:14.998 13628-13628/com.adverscribe.myapplication D/NetworkSecurityConfig: No Network Security Config specified, using platform default
01-23 18:34:15.123 13628-13650/com.adverscribe.myapplication I/Adreno: QUALCOMM build : ead2395, I23cc4685e6
Build Date : 04/11/17
OpenGL ES Shader Compiler Version: XE031.09.00.04
Local Branch :
Remote Branch : quic/gfx-adreno.lnx.1.0.r5-rel
Remote Branch : NONE
Reconstruct Branch : NOTHING
01-23 18:34:15.137 13628-13650/com.adverscribe.myapplication I/OpenGLRenderer: Initialized EGL, version 1.4
01-23 18:34:15.137 13628-13650/com.adverscribe.myapplication D/OpenGLRenderer: Swap behavior 1
01-23 18:34:15.170 13628-13628/com.adverscribe.myapplication W/art: Before Android 4.1, method int android.support.v7.widget.ListViewCompat.lookForSelectablePosition(int, boolean) would have incorrectly overridden the package-private method in android.widget.ListView
01-23 18:34:15.205 13628-13628/com.adverscribe.myapplication I/Timeline: Timeline: Activity_idle id: android.os.BinderProxy@ca6d04c time:134394442
01-23 18:34:16.628 13628-13628/com.adverscribe.myapplication I/ViewRootImpl: ViewRoot's KeyEvent { action=ACTION_DOWN, keyCode=KEYCODE_BACK, scanCode=0, metaState=0, flags=0x48, repeatCount=0, eventTime=134395859, downTime=134395859, deviceId=-1, source=0x101 } to DecorView@67df74[MainActivity]
01-23 18:34:16.630 13628-13628/com.adverscribe.myapplication I/AudioManagerEx: AudioManagerEx created
01-23 18:34:16.709 13628-13628/com.adverscribe.myapplication I/ViewRootImpl: ViewRoot's KeyEvent { action=ACTION_UP, keyCode=KEYCODE_BACK, scanCode=0, metaState=0, flags=0x48, repeatCount=0, eventTime=134395942, downTime=134395859, deviceId=-1, source=0x101 } to DecorView@67df74[MainActivity]
您的api没有返回有效的JSON
stdClass Object([stock_division_id] => 1[stock_division_name] => Men[stock_division_status] => 1[created_date] => 2018 - 01 - 12 11: 59: 00[updated_date] => 2018 - 01 - 12 11: 59: 22) stdClass Object([stock_division_id] => 2[stock_division_name] => Women[stock_division_status] => 1[created_date] => 2018 - 01 - 12 11: 59: 44[updated_date] => 2018 - 01 - 12 11: 59: 44) {
"code": 200,
"message": "SUCCESS",
"data": {
"menu": [{
"division": {
"stock_division_id": "1",
"stock_division_name": "Men",
"stock_division_status": "1",
"created_date": "2018-01-12 11:59:00",
"updated_date": "2018-01-12 11:59:22"
},
"cat": [{
"stock_category_id": "1",
"stock_division_id": "1",
"stock_category_name": "T-Shirts",
"stock_category_status": "1",
"created_date": "2018-01-12 12:00:14",
"updated_date": "2018-01-12 12:00:14"
}]
}, {
"division": {
"stock_division_id": "2",
"stock_division_name": "Women",
"stock_division_status": "1",
"created_date": "2018-01-12 11:59:44",
"updated_date": "2018-01-12 11:59:44"
},
"cat": [{
"stock_category_id": "2",
"stock_division_id": "2",
"stock_category_name": "T-Shirts",
"stock_category_status": "1",
"created_date": "2018-01-12 12:02:24",
"updated_date": "2018-01-12 12:02:24"
}]
}]
}
}
试图使用Refundation以JSON格式发送信息,但它进入Refundation的方法并抛出以下错误: 到目前为止,我已经尝试使用以下链接中的答案来解决这个问题:1)改型API异常?2) 使用JsonReader。setLenient(true)在第1行第1列路径接受格式错误的JSON$ 这是我的代码: 改装接口: 与连接相关的主要活动: 用户类别: 服务器端希望JSON如下所示: 我知道st
我正在尝试为我的应用程序创建忘记密码脚本。当我运行我的apk并尝试保留我的密码时,我得到了一个错误,上面写着使用JsonReader。setLenient(true)要在第1行第1列路径$Error处接受格式错误的JSON,我的apk中一切正常,我可以登录、注销或注册,但当我重置密码时,我得到了JsonReader。设置宽容(真)错误。我的apk json正在工作,它是正确的。请帮帮我。我在分享我
这个错误是什么?我怎样才能解决这个问题?我的应用程序正在运行,但无法加载数据。这是我的错误:使用JsonReader.setLenient(true)在第1行第1列路径$接受格式错误的JSON 这是我的片段: 请求接口: 总是这个错误不是关于你的json,它可能来自你的错误请求,为了更好地处理,首先在邮递员中检查你的请求,如果你得到了响应,然后将你的json响应与你的模型进行比较,如果没有错误,那
在登录时间我得到了这个错误,请不要降级,如果你知道任何解决方案,请指导我。我也检查了不同的堆栈溢出后,但他们都在谈论修剪字符串或其他改造的解决方案,但我不能解决它。我用截击。 我的Json文件:- 这是我的Java类:-
我想通过php party将数据添加到MySQL。但是我一直失败。检查网站上的数据。仍然没有解决方案。我哪里出错了? 我尝试了以下方法,但似乎无法解决问题。如何修复“使用JsonReader”。setLenient(true)在Android Studio中的第1行第1列path$'错误处接受格式错误的JSON,并使用JsonReader。setLenient(true)在第1行第1列路径接受格式
当我尝试访问我的Web服务,在onFailure我得到在LogCat. i可以从POSTMAN得到响应 这是邮差的回复 在线更新 方法 PHP服务响应 UpdateOrderResponse模块类 使现代化 我添加了以进行改装。就像下面 然后得到另一个错误在它是