JSON text component parser throws unhandled exceptions when incorrect data type was provided
The bug
The JSON text component parser throws unhandled exceptions when data of an incorrect type was provided. For example:
- "text":[]
- "text":"","extra":1
When using this while typing in chat the client crashes with the description keyPressed event handler, in command blocks the exception is written to the log.
Description: charTyped event handler
java.lang.ClassCastException: com.google.gson.JsonPrimitive cannot be cast to com.google.gson.JsonObject
at com.google.gson.JsonObject.getAsJsonObject(JsonObject.java:191)
...
Description: charTyped event handler
java.lang.ClassCastException: com.google.gson.JsonPrimitive cannot be cast to com.google.gson.JsonArray
at com.google.gson.JsonObject.getAsJsonArray(JsonObject.java:181)
...
Description: keyPressed event handler
java.lang.IllegalStateException
at com.google.gson.JsonArray.getAsString(JsonArray.java:215)
...
How to reproduce
- Use the following command
/setblock ~ ~ ~ command_block{Command:"/tellraw @p {\"text\":[]}",auto:1b} - Look in the log