Use JsonReader.setLenient(true) to accept malformed JSON at line 1 column 1 path $
See original GitHub issueI get this error when sending a get request
this is my code:
** build.gradle ** `apply plugin: ‘com.android.application’
android { compileSdkVersion 25 buildToolsVersion “26.0.2” defaultConfig { applicationId “ir.supersoft.androidfastnetworking” minSdkVersion 16 targetSdkVersion 25 versionCode 1 versionName “1.0” testInstrumentationRunner “android.support.test.runner.AndroidJUnitRunner” } buildTypes { release { minifyEnabled false proguardFiles getDefaultProguardFile(‘proguard-android.txt’), ‘proguard-rules.pro’ } } }
dependencies { compile fileTree(dir: ‘libs’, include: [‘*.jar’]) compile ‘com.android.support:appcompat-v7:25.3.1’ compile ‘com.android.support.constraint:constraint-layout:1.0.2’ compile ‘com.amitshekhar.android:android-networking:1.0.0’ compile ‘com.library.tangxiaolv:telegramgallery:1.0.3’ } `
User.java `public class User {
public int id; public String first_name; public String last_name; public int age; } `
MainActivity.java AndroidNetworking.initialize(getApplicationContext());
`AndroidNetworking.get(“http://sekeh.gigfa.com/getUsers.php”) .setTag(“test”) .setPriority(Priority.LOW) .build() .getAsOkHttpResponseAndObjectList(User.class, new OkHttpResponseAndParsedRequestListener<List<User>>() { @Override public void onResponse(Response okHttpResponse, List<User> users) { // do anything with response Log.d(“amirhosein”, "userList size : " + users.size()); for (User user : users) { Log.d(“amirhosein”, "id : " + user.id); Log.d(“amirhosein”, "firstname : " + user.first_name); Log.d(“amirhosein”, "lastname : " + user.last_name); Log.d(“amirhosein”, "age : " + user.age); } }
@Override
public void onError(ANError anError) {
Log.e("amirhosein", "error: " + anError.getLocalizedMessage());
}
});
`
i test that in localhost(xampp) but it`s worked!
keep in mind that my androidnetworking version is 1.0.0 because 1.0.1 need to appcompatv7:27.0.2
Issue Analytics
- State:
- Created 5 years ago
- Comments:14 (6 by maintainers)
Top GitHub Comments
Your response is not json. It is text/html so it is unable to parse. Send application/json from the server as the content-type.
In my case from the server side, the content type is already JSON but I’m still getting the same error.