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.

Have to set lenient on JsonReader for RPC

See original GitHub issue

I am trying to connect to a basic auth web3 node. If basic auth fails, it returns back non-json text to say that you’re not authenticated… You have to set leninet = true for moshi to be able to return this text back without the client failing. Or perhaps check if it’s json, if not jsonify it before handing it to moshi?

Caused by: com.squareup.moshi.JsonEncodingException: Use JsonReader.setLenient(true) to accept malformed JSON at path $
	at com.squareup.moshi.JsonReader.syntaxError(JsonReader.java:220)
	at com.squareup.moshi.JsonUtf8Reader.checkLenient(JsonUtf8Reader.java:1031)
	at com.squareup.moshi.JsonUtf8Reader.doPeek(JsonUtf8Reader.java:344)
	at com.squareup.moshi.JsonUtf8Reader.peek(JsonUtf8Reader.java:171)
	at com.squareup.moshi.JsonAdapter$2.fromJson(JsonAdapter.java:134)
	at com.squareup.moshi.JsonAdapter.fromJson(JsonAdapter.java:36)
	at org.kethereum.rpc.EthereumRPC.getBlockNumberString(EthereumRPC.kt:34)

Issue Analytics

  • State:open
  • Created 5 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
ligicommented, Aug 8, 2018

I think it should throw an exception - perhaps it should be a different exception though. Like NotAuthenticatedException. So I think the solution would be to check if the code is != 200 -> and if it is unauthenticated -> throw this error

0reactions
hshar7commented, Aug 15, 2018

@ligi Sure please do! It isn’t exposed publicly but you can can your own instance at https://kaleido.io/ it’s really easy to create one. Let me know if you have any questions!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Use JsonReader.setLenient(true) to accept malformed ...
This is a well-known issue and based on this answer you could add setLenient : Gson gson = new GsonBuilder() .setLenient() .create(); Retrofit...
Read more >
Example usage for com.google.gson.stream JsonReader ...
Introduction. In this page you can find the example usage for com.google.gson.stream JsonReader setLenient. Prototype. public final void setLenient(boolean ...
Read more >
“com.google.gson.stream.MalformedJsonException: Use ...
com.google.gson.stream.MalformedJsonException: Use JsonReader.setLenient(true) to accept malformed JSON. javascript by Uptight Unicorn on Aug 23 2020 ...
Read more >
pact-jvm
when i try to download using the above plugin i get the following error ``` com.google.gson.stream.MalformedJsonException: Use JsonReader.setLenient(true) ...
Read more >
Use JsonReader.setLenient(true) to accept malformed ...
Use JsonReader.setLenient(true) to accept malformed JSON at line 1 column 1 path $. Home ...
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