question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Use JsonReader.setLenient(true) to accept malformed JSON at line 1 column 1 path $

See original GitHub issue

I 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:closed
  • Created 5 years ago
  • Comments:14 (6 by maintainers)

github_iconTop GitHub Comments

16reactions
amitshekhariitbhucommented, Apr 19, 2018

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.

1reaction
grandeefidelcommented, Oct 13, 2022

In my case from the server side, the content type is already JSON but I’m still getting the same error.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Use JsonReader.setLenient(true) to accept malformed JSON ...
And this is my Error: Use JsonReader.setLenient(true) to accept malformed JSON at line 1 column 1 path $. This is my fragment :...
Read more >
MalformedJsonException: Use JsonReader.setLenient(true)
MalformedJsonException : Use JsonReader.setLenient(true) to accept malformed JSON at line 2 column 2 path $. Here is my script:
Read more >
jsonreader.setlenient(true) to accept malformed json ... - Reddit
jsonreader.setlenient(true) to accept malformed json at line 1 column 1 path $. Hello,. I was editing my team in minecraft like this:.
Read more >
MalformedJSONException: Resolving JSON Parsing Errors
JsonParseException: com.google.gson.stream.MalformedJsonException: Use JsonReader.setLenient(true) to accept malformed JSON at line 1 column 1 path $ at ...
Read more >
Use JsonReader.setLenient(true) to accept malformed JSON ...
Getting the exception on sending images as "MalformedJsonException: Use JsonReader.setLenient(true) to accept malformed JSON at line 2 column 2 path" result ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found