Java Gson – parsing json to java token by token

Converting json to a java object

In the earlier tutorials we saw how to convert json to a java object. In This tutorial we see how to parse json and obtain individual tokens. Although this may seem like a cumbersome way to build java object from json, however it is extremely powerful and may be a good choice if you need a very high level of control over the parsing. We use the JsonReader class to read the json as a stream of tokens. The beginning of an object or an array is also a token. Here’s a detailed example.

One thought on “Java Gson – parsing json to java token by token

  • February 20, 2017 at 3:21 pm

    why won’t this work?


Leave a Reply

Your email address will not be published. Required fields are marked *