ParsingException in Response#getArray()
See original GitHub issueGeneral Troubleshooting
- I have checked for similar issues.
- I have updated to the latest JDA version
- I have checked the branches or the maintainers’ PRs for upcoming bug fixes.
Bug Report
When creating a RestAction to retrieve guild data (e.g. all channels) the RestActions fails with a ParsingException.
I tried to ask on the Discord server but either no one could help me or my question got lost between other questions (twice). What I’m trying to do is to save all the data from a guild to local files (messages, attachments, metadata …). This should be the raw JSON to avoid having to manually go through everything and to ensure that no data gets lost.
Expected Behavior
The RestAction should have successfully returned a DataArray (i think).
Code Example or Reproduction Steps
Route.CompiledRoute route = Route.Guilds.GET_CHANNELS.compile(/*valid guild id*/);
DataArray data = new RestActionImpl<DataArray>(jda, route, (response, dataArrayRequest) -> response.getArray()).complete();
Code for JDABuilder or DefaultShardManagerBuilder Used
JDABuilder.createDefault(token)
.setMemberCachePolicy(MemberCachePolicy.NONE);
.setStatus(OnlineStatus.IDLE);
.build();
Exception or Error
StackTrace
java.lang.IllegalStateException: An error occurred while parsing the response for a RestAction
net.dv8tion.jda.api.requests.Response.parseBody(Response.java:220)
net.dv8tion.jda.api.requests.Response.parseBody(Response.java:182)
net.dv8tion.jda.api.requests.Response.get(Response.java:124)
net.dv8tion.jda.api.requests.Response.getObject(Response.java:105)
de.eldritch.discord.turtlecrawler.task.tasks.GuildTask.lambda$handleMetadata$0(GuildTask.java:120)
net.dv8tion.jda.internal.requests.RestActionImpl.handleSuccess(RestActionImpl.java:278)
net.dv8tion.jda.internal.requests.RestActionImpl.handleResponse(RestActionImpl.java:268)
net.dv8tion.jda.api.requests.Request.handleResponse(Request.java:259)
net.dv8tion.jda.internal.requests.Requester.execute(Requester.java:237)
net.dv8tion.jda.internal.requests.Requester.execute(Requester.java:141)
net.dv8tion.jda.internal.requests.Requester.execute(Requester.java:124)
net.dv8tion.jda.internal.requests.ratelimit.BotRateLimiter$Bucket.run(BotRateLimiter.java:478)
java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:539)
java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
java.base/java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:304)
java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
java.base/java.lang.Thread.run(Thread.java:833)
// caused by:
net.dv8tion.jda.api.exceptions.ParsingException: com.fasterxml.jackson.databind.exc.MismatchedInputException: Cannot deserialize instance of `java.util.HashMap<java.lang.Object,java.lang.Object>` out of START_ARRAY token at [Source: (BufferedReader); line: 1, column: 1]
net.dv8tion.jda.api.utils.data.DataObject.fromJson(DataObject.java:184)
net.dv8tion.jda.api.requests.Response.parseBody(Response.java:204)
net.dv8tion.jda.api.requests.Response.parseBody(Response.java:182)
net.dv8tion.jda.api.requests.Response.get(Response.java:124)
net.dv8tion.jda.api.requests.Response.getObject(Response.java:105)
de.eldritch.discord.turtlecrawler.task.tasks.GuildTask.lambda$handleMetadata$0(GuildTask.java:120)
net.dv8tion.jda.internal.requests.RestActionImpl.handleSuccess(RestActionImpl.java:278)
net.dv8tion.jda.internal.requests.RestActionImpl.handleResponse(RestActionImpl.java:268)
net.dv8tion.jda.api.requests.Request.handleResponse(Request.java:259)
net.dv8tion.jda.internal.requests.Requester.execute(Requester.java:237)
net.dv8tion.jda.internal.requests.Requester.execute(Requester.java:141)
net.dv8tion.jda.internal.requests.Requester.execute(Requester.java:124)
net.dv8tion.jda.internal.requests.ratelimit.BotRateLimiter$Bucket.run(BotRateLimiter.java:478)
java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:539)
java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
java.base/java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:304)
java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
java.base/java.lang.Thread.run(Thread.java:833)
// caused by:
com.fasterxml.jackson.databind.exc.MismatchedInputException: Cannot deserialize instance of `java.util.HashMap<java.lang.Object,java.lang.Object>` out of START_ARRAY token at [Source: (BufferedReader); line: 1, column: 1]
com.fasterxml.jackson.databind.exc.MismatchedInputException.from(MismatchedInputException.java:59)
com.fasterxml.jackson.databind.DeserializationContext.reportInputMismatch(DeserializationContext.java:1442)
com.fasterxml.jackson.databind.DeserializationContext.handleUnexpectedToken(DeserializationContext.java:1216)
com.fasterxml.jackson.databind.DeserializationContext.handleUnexpectedToken(DeserializationContext.java:1126)
com.fasterxml.jackson.databind.deser.std.StdDeserializer._deserializeFromEmpty(StdDeserializer.java:639)
com.fasterxml.jackson.databind.deser.std.MapDeserializer.deserialize(MapDeserializer.java:360)
com.fasterxml.jackson.databind.deser.std.MapDeserializer.deserialize(MapDeserializer.java:29)
com.fasterxml.jackson.databind.ObjectMapper._readMapAndClose(ObjectMapper.java:4202)
com.fasterxml.jackson.databind.ObjectMapper.readValue(ObjectMapper.java:3234)
net.dv8tion.jda.api.utils.data.DataObject.fromJson(DataObject.java:179)
net.dv8tion.jda.api.requests.Response.parseBody(Response.java:204)
net.dv8tion.jda.api.requests.Response.parseBody(Response.java:182)
net.dv8tion.jda.api.requests.Response.get(Response.java:124)
net.dv8tion.jda.api.requests.Response.getObject(Response.java:105)
de.eldritch.discord.turtlecrawler.task.tasks.GuildTask.lambda$handleMetadata$0(GuildTask.java:120)
net.dv8tion.jda.internal.requests.RestActionImpl.handleSuccess(RestActionImpl.java:278)
net.dv8tion.jda.internal.requests.RestActionImpl.handleResponse(RestActionImpl.java:268)
net.dv8tion.jda.api.requests.Request.handleResponse(Request.java:259)
net.dv8tion.jda.internal.requests.Requester.execute(Requester.java:237)
net.dv8tion.jda.internal.requests.Requester.execute(Requester.java:141)
net.dv8tion.jda.internal.requests.Requester.execute(Requester.java:124)
net.dv8tion.jda.internal.requests.ratelimit.BotRateLimiter$Bucket.run(BotRateLimiter.java:478)
java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:539)
java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
java.base/java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:304)
java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
java.base/java.lang.Thread.run(Thread.java:833)
Issue Analytics
- State:
- Created a year ago
- Comments:7
Top Results From Across the Web
com.grack.nanojson.JsonParser$JsonParserContext.from ...
JsonObject parentObject = JsonParser.object().from(in); JsonArray channelsArray ... e) { throw new ParsingException("Could not parse json response", ...
Read more >JDA/GuildImpl.java at master · DV8FromTheWorld/JDA - GitHub
response.getArray().stream(DataArray::getObject). ... DataArray arr = response.getArray(); ... catch (ParsingException | ClassCastException ex).
Read more >net.dv8tion.jda.api.entities.User Java Examples
addField(languageContext.get(leaderboardKey), lb.stream() ... getEntityBuilder(); final DataArray array = response.getArray(); final List<User> users = new ...
Read more >Java JsonParser类代码示例- Java编程经验-OGeek|极客世界-中国 ...
clientId() + "&limit=10"; String response = dl.download(url); try { JsonArray ... e) { throw new ParsingException("Could not parse json response", e); } }....
Read more >https://git.lain.faith/be-gay-do-crimes/NewPipeExt...
getRequest(), response. ... ParsingException { + public void testGetInvidiousIdfromUrl() throws ParsingException { assertEquals("TglNG-yjabU", linkHandler.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
That body should parse just fine with the code you have provided in the issue. If you can make a proper example with a failure case and an example body which fails to parse, please open a new issue with the consistent reproduction steps. Your code in the initial issue description works fine, and the body you have shown also parses into an array correctly.
Make sure that you use
getArray()
forRoute.Guilds.GET_CHANNELS
andgetObject()
forRoute.Guilds.GET_GUILD
. That works fine in all my testing.Sorry again, I uncommented the wrong line :c removed