google / google/gson

JsonSyntaxException Javadoc wrong or Gson.fromJson() throwing a wrong exception

Open
#1,138 2 comments 0 reactions 0 assignees View on GitHub
documentation enhancement
Dominant language
Java
Stars
24.2k
Forks
4.5k
Avg merge
6d 4h
Merged PRs (30d)
12

Description

https://www.javadoc.io/doc/com.google.code.gson/gson/2.8.1 says

> This exception is raised when Gson attempts to read (or write) a malformed JSON element.

However, it throws the exception even if an element or a JSON is well-formed and syntactically correct. For example, when de-serializing JSON input with `gson.fromJson(json, MyType.class)`, if a string type is given when an array type is expected, it will throw a syntax exception, even if the input is syntactically correct.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.