Reader small image

You're reading from  Instant GSON

Product typeBook
Published inAug 2013
Reading LevelIntermediate
PublisherPackt
ISBN-139781783282036
Edition1st Edition
Languages
Right arrow
Author (1)
Sandeep Patel
Sandeep Patel
author image
Sandeep Patel

http://www.packtpub.com/developing-responsive-web-applications-with-ajax-and-jquery/book
Read more about Sandeep Patel

Right arrow

Top 12 features you need to know about


In this section, you will learn about the top features supported by the GSON library. You will also learn about how to implement these features.

Java objects support

Objects in GSON are referred as types of JsonElement:

The GSON library can convert any user-defined class objects to and from the JSON representation. The Student class is a user-defined class, and GSON can serialize any Student object to JSON.

The Student.java class is as follows:

public class Student {

private String name;

private String subject;

privateint mark;

public String getName() {
return name;
}

public void setName(String name) {
this.name = name;
}

public String getSubject() {
return subject;
}

public void setSubject(String subject) {
this.subject = subject;
}

public int getMark() {
return mark;
}

public void setMark(int mark) {
this.mark = mark;
}

}

The code for JavaObjectFeaturesUse.java is as follows:

import com.google.gson.Gson;
importcom.packt.chapter.vo.Student;

public...
Previous PageNext Page
You have been reading a chapter from
Instant GSON
Published in: Aug 2013Publisher: PacktISBN-13: 9781783282036
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
undefined
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $15.99/month. Cancel anytime

Author (1)

author image
Sandeep Patel

http://www.packtpub.com/developing-responsive-web-applications-with-ajax-and-jquery/book
Read more about Sandeep Patel