Skip to content

Gson: Convert String to JsonObject without POJO

Gson: convert String to JsonObject without POJO example shows how to convert String to JsonObject without using the POJO class using the Gson library in Java.

How to convert String to JsonObject without POJO?

The Google Gson library provides the fromJson method that converts given String JSON data to various types of objects or types. We can convert the JSON data to a Java POJO (Plain Old Java Object) or we can directly convert String to JsonObject with no POJO using the same fromJson method.

Here is the JSON we want to convert to a JsonObject.

Here is an example program to do that.

Output

Please let me know your views in the comments section below.

About the author

Leave a Reply

Your email address will not be published.