java.lang.NullPointerException while reading value from json to java object - java

Here I am reading json value from youtube to java.
I am getting values properly except the thumbnail data while getting thumbnail object value i am getting java.lang.NullPointerException
public class JsonVideoDetais {
public static void main(String... args) {
BufferedReader reader = null;
StringBuilder buffer = null;
try {
String link = "https://gdata.youtube.com/feeds/api/videos/" + "aa_wFClyiVE" + "?v=2&alt=jsonc";
URL url = new URL(link);
reader = new BufferedReader(new InputStreamReader(url.openStream(), "UTF-8"));
buffer = new StringBuilder();
int read;
char[] chars = new char[1024];
while ((read = reader.read(chars)) != -1) {
buffer.append(chars, 0, read);
}
} catch (Exception e) {
} finally {
if (reader != null) {
try {
reader.close();
} catch (IOException ex) {
Logger.getLogger(JsonVideoDetais.class.getName()).log(Level.SEVERE, null, ex);
}
}
}
videoDetails data;
data = new Gson().fromJson(buffer.toString(), videoDetails.class);
System.out.println(data.getData().getTitle());
System.out.println(data.getData().getTn().getHqDefault());
System.out.println(data.getData().getTn().getSqDefault());
}
}
class videoDetails {
private Data data;
public Data getData() {
return data;
}
public void setData(Data data) {
this.data = data;
}
public String toString() {
return String.format("data:%s", data);
}
}
class Data {
private String id;
private String title;
private String description;
private int duration;
private Thumbnail tn;
public Thumbnail getTn() {
return tn;
}
public void setTn(Thumbnail tn) {
this.tn = tn;
}
public int getDuration() {
return duration;
}
public void setDuration(int duration) {
this.duration = duration;
}
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
public String toString() {
return String.format("title:%s,id:%s,description:%s,tn:%s,duration:%d", title, id, description, tn, duration);
}
}
class Thumbnail {
private String sqDefault;
private String hqDefault;
public String getSqDefault() {
return sqDefault;
}
public void setSqDefault(String sqDefault) {
this.sqDefault = sqDefault;
}
public String getHqDefault() {
return hqDefault;
}
public void setHqDefault(String hqDefault) {
this.hqDefault = hqDefault;
}
public String toString() {
return String.format("sqDefault:%s,hqDefault:%s", hqDefault, sqDefault);
}
}
I am getting following exception
Exception in thread "main" java.lang.NullPointerException
at utility.JsonVideoDetais.main(JsonVideoDetais.java:52)
while calling
System.out.println(data.getData().getTn().getHqDefault());
System.out.println(data.getData().getTn().getSqDefault());
If you wll see this link. It is having value for sqDefault and hqDefault
I would like to fetch the value of sqDefault and hqDefault.
How to do this.

In your Data class, i created an object like this. I guess the Thumbnail object is getting set to thumbnail, tn is not working on my side too.
private Thumbnail thumbnail;// instead of tn
and the resultant output is : -
Blood Glucose Hindi - Dr. Anup, MD Teaches Series
https://i1.ytimg.com/vi/aa_wFClyiVE/hqdefault.jpg
https://i1.ytimg.com/vi/aa_wFClyiVE/default.jpg

Using debugger to find out which object is null is fastest way to solve your problem.
OR
Find the null return value with the following code:
System.out.println(data);
System.out.println(data.getData());
System.out.println(data.getData().getTn());
--The following text are newly added-----------------
Well, I have run your program on my laptop, and it seem that the json response of https://gdata.youtube.com/feeds/api/videos/aa_wFClyiVE?v=2&alt=jsonc#data/thumbnail/hqDefault contains no tn field at all. That's why you always got null value.

Related

How to save and load Objects to and from a file

I'm gonna be honest I am panicking. I am doing an exam in a Java course and I have been stuck for some time now.
I have to implement a RSS Feader and I am currently doing methods to save and load subscribed feeds. I thought I got the saveSubscribedFeeds method right because it passes the JUnit Test but I am starting to think I have some kind of error in there so that the loadSubscribeFeeds method cannot work properly.
Here is the saveSubscribedFeeds method:
public void saveSubscribedFeeds(List<Feed> feeds, File feedsFile) {
FileWriter writer = null;
try {
writer = new FileWriter(feedsFile);
for(Feed f: feeds) {
writer.write(f + System.lineSeparator());
}
writer.close();
} catch (IOException e) {
e.getMessage();
}
}
For the loadSubscribedFeed method I already tried a Scanner, BufferedReader and FileInputStream and ObjectInputStream but nothing works. This is my current method:
public List<Feed> loadSubscribedFeeds(File feedsFile) {
Scanner s = null;
try {
s = new Scanner(feedsFile);
} catch (FileNotFoundException e) {
e.printStackTrace();
}
List<String> listString = new ArrayList<>();
List<Feed> listFeed = new ArrayList<>();
while (s.hasNextLine()) {
listString.add(s.nextLine());
}
for(String f : listString) {
listFeed.add(new Feed(f));
}
return listFeed;
}
here is also the Feed class:
public class Feed implements Serializable, Comparable<Feed> {
private static final long serialVersionUID = 1L;
private String url;
private String title;
private String description;
private String publishedDateString;
private List<Entry> entries;
public Feed(String url) {
super();
this.url = url;
this.entries = new ArrayList<Entry>();
this.title = "";
this.description = "";
this.publishedDateString = "";
}
/**
* Creates an instance of a Feed and transfers the feed
* data form a SyndFeed object to the new instance.
* #param url The URL string of this feed
* #param sourceFeed The SyndFeed object holding the data for this feed instance
*/
public Feed(String url, SyndFeed sourceFeed) {
this(url);
setTitle(sourceFeed.getTitle());
setDescription(sourceFeed.getDescription());
if (sourceFeed.getPublishedDate() != null)
setPublishedDateString(FeaderUtils.DATE_FORMAT.format(sourceFeed.getPublishedDate()));
for (SyndEntry entryTemp : sourceFeed.getEntries()) {
Entry entry = new Entry(entryTemp.getTitle());
entry.setContent(entryTemp.getDescription().getValue());
entry.setLinkUrl(entryTemp.getLink());
entry.setParentFeedTitle(getTitle());
if (entryTemp.getPublishedDate() != null) {
entry.setPublishedDateString(FeaderUtils.DATE_FORMAT.format(entryTemp.getPublishedDate()));
}
addEntry(entry);
}
}
public String getUrl() {
return url;
}
public void setTitle(String title) {
this.title = title != null ? title : "";
}
public String getTitle() {
return title;
}
public void setDescription(String description) {
this.description = description != null ? description : "";
}
public String getDescription() {
return description;
}
public void setPublishedDateString(String publishedDateString) {
this.publishedDateString = publishedDateString != null ? publishedDateString : "";
}
public String getPublishedDateString() {
return publishedDateString;
}
/**
* Returns a short string containing a combination of meta data for this feed
* #return info string
*/
public String getShortFeedInfo() {
return getTitle() + " [" +
getEntriesCount() + " entries]: " +
getDescription() +
(getPublishedDateString() != null && getPublishedDateString().length() > 0
? " (updated " + getPublishedDateString() + ")"
: "");
}
public void addEntry(Entry entry) {
if (entry != null) entries.add(entry);
}
public List<Entry> getEntries() {
return entries;
}
public int getEntriesCount() {
return entries.size();
}
#Override
public boolean equals(Object obj) {
return (obj instanceof Feed)
&& ((Feed)obj).getUrl().equals(url);
}
#Override
public int hashCode() {
return url.hashCode();
}
#Override
public String toString() {
return getTitle();
}
#Override
public int compareTo(Feed o) {
return getPublishedDateString().compareTo(o.getPublishedDateString());
}
}
Maybe someone out there will be able to help me or guide me in the correct direction.
Thanks already in advance.

Java: Arraylist out of bounds when processing file [duplicate]

This question already has answers here:
What causes a java.lang.ArrayIndexOutOfBoundsException and how do I prevent it?
(26 answers)
Closed 2 years ago.
I am trying to create an ArrayList that reads a .csv file, processes the data into an ArrayList, and then print the list out.
My code so far.
The BankRecords class
import java.io.*;
import java.util.*;
public class BankRecords
{
String sex, region, married, save_act, current_act, mortgage, pep;
int children;
double income;
private String id;
private int age;
public BankRecords(String gender, String area, String marriage, String SaveAccount, String CurrentAccount, String HouseBill, String pepp, int minors, double paycheck, String identification, int years)
{
this.sex = gender;
this.region = area;
this.married = marriage;
this.save_act = SaveAccount;
this.current_act = CurrentAccount;
this.mortgage = HouseBill;
this.pep = pepp;
this.children = minors;
this.income = paycheck;
this.id = identification;
this.age = years;
}
public String getId()
{
return id;
}
public void setId(String id)
{
this.id = id;
}
public String getSex()
{
return sex;
}
public void setSex(String sex)
{
this.sex = sex;
}
public String getRegion()
{
return region;
}
public void setRegion(String region)
{
this.region = region;
}
public String getMarried()
{
return married;
}
public void setMarried(String married)
{
this.married = married;
}
public String getSave_act()
{
return save_act;
}
public void setSave_act(String save_act)
{
this.save_act = save_act;
}
public String getCurrent_act()
{
return current_act;
}
public void setCurrent_act(String current_act)
{
this.current_act = current_act;
}
public String getMortgage()
{
return mortgage;
}
public void setMortgage(String mortgage)
{
this.mortgage = mortgage;
}
public String getPep()
{
return pep;
}
public void setPep(String pep)
{
this.pep = pep;
}
public int getAge()
{
return age;
}
public void setAge(int age)
{
this.age = age;
}
public int getChildren()
{
return children;
}
public void setChildren(int children)
{
this.children = children;
}
public double getIncome()
{
return income;
}
public void setIncome(double income)
{
this.income = income;
}
}
The Client abstract class
import java.io.*;
import java.util.*;
public abstract class Client
{
static ArrayList<List<String>> BankArray = new ArrayList<>(25);
static BankRecords robjs[] = new BankRecords[600];
public static void readData()
{
try
{
BufferedReader br;
String filepath = "C:\\Users\\eclipse-workspace\\Bank_Account\\src\\bank-Detail.csv";
br = new BufferedReader(new FileReader (new File(filepath)));
String line;
while ((line = br.readLine()) != null)
{
BankArray.add(Arrays.asList(line.split(",")));
}
}
catch (Exception e)
{
e.printStackTrace();
}
processData();
}
public static void processData()
{
int idx=0;
for (List<String> rowData: BankArray)
{
robjs[idx] = new BankRecords(null, null, null, null, null, null, null, idx, idx, null, idx);
robjs[idx].setId(rowData.get(0));
robjs[idx].setAge(Integer.parseInt(rowData.get(1)));
idx++;
}
printData();
}
public static void printData()
{
System.out.println("ID\tAGE\tSEX\tREGION\tINCOME\tMORTGAGE");
int final_record = 24;
for (int i = 0; i < final_record; i++)
{
System.out.println(BankArray.get(i) + "\t ");
}
}
}
The BankRecordsTest class (extends Client)
import java.util.*;
import java.io.*;
public class BankRecordsTest extends Client
{
public static void main(String args [])
{
readData();
}
}
The error
And here is the error.
Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 1
at java.util.Arrays$ArrayList.get(Unknown Source)
at Client.processData(Client.java:33)
at Client.readData(Client.java:24)
at BankRecordsTest.main(BankRecordsTest.java:7)
I'm not sure what the index problem is. Do note that if you run the ReadData() and PrintData() functions separately, the code runs fine but the ProcessData() method causes issues.
I think your data is likely not clean and you are making assumptions about the length of your array. The error you are getting stems from this line:
robjs[idx].setAge(Integer.parseInt(rowData.get(1)));
Clearly, rowData doesn't have 2 items (or more). This is why you are getting ArrayIndexOutOfBoundsException. So you want to check where your variable was initialized. You quickly realize it comes from
for (List<String> rowData: BankArray)
So then, the following question is where BankArray gets initialized. That happens in 2 places. First of all
static ArrayList<List<String>> BankArray = new ArrayList<>(25);
You are creating an empty list. So far so good. Note that you don't need to (and therefore shouldn't) initialize with a size. Lists are not like arrays insofar as they can easily grow and you don't need to give their size upfront.
The second place is
BankArray.add(Arrays.asList(line.split(",")));
This is likely where the issue comes from. Your row variable contains the results of Arrays.asList(line.split(",")). So the size of that list depends on the number of commas in that string you are reading. If you don't have any commas, then the size will be 1 (the value of the string itself). And that's what leads me to concluding you have a data quality issue.
What you should really do is add a check in your for (List<String> rowData: BankArray) loop. If for instance, you expect 2 fields, you could write something along the lines of:
if (rowData.size()<2){
throw new Exception("hmmm there's been a kerfuffle');
}
HTH

Java - Type Mismatch: Cannot Convert From Element type String[] to List<String>

I'm unfamiliar with getters and setters (and basically just Java) but I have to use them for this assignment, so if I did anything wrong with those please tell me.
The more important issue is the error that I am getting on my method. The word for word instructions from my assignment for the particular method I'm working on are:
Your processData() method should take all the record data from your ArrayList and add the data into each of your instance fields via your setters.
But I keep getting an error that says:
Type mismatch: cannot convert from element type String[] to List
On the line that says "for (List<String> rowData: content)" on the word content.
Thank you very much for any help you can give me.
My code so far:
public abstract class Client {
String file = "bank-Detail.csv";
ArrayList<String[]> bank = new ArrayList<>();
static Client o[] = new Client[12];
public Client(String file) {
this.file = file;
}
private String ID;
private String Age;
private String Sex;
private String Region;
private String Income;
private String Married;
private String Children;
private String Car;
private String Save_Act;
private String Current_Act;
private String Mortgage;
private String Pep;
public List<String[]> readData() throws IOException {
//initialize variable
int count = 0;
//name file
String file = "bank-Detail.txt";
//make array list
List<String[]> content = new ArrayList<>();
//trycatch for exceptions
try {
//file reader
BufferedReader br = new BufferedReader(new FileReader(file));
//string to add lines to
String line = "";
while ((line = br.readLine()) != null) {
content.add(line.split(","));
}
} catch (FileNotFoundException e) {
e.printStackTrace();
}
processData(content);
return content;
}
public String getID() {
return ID;
}
public void setID(String ID) {
this.ID = ID;
}
public String getAge() {
return Age;
}
public void setAge(String age) {
this.Age = age;
}
public String getSex() {
return Sex;
}
public void setSex(String sex) {
Sex = sex;
}
public String getRegion() {
return Region;
}
public void setRegion(String region) {
Region = region;
}
public String getIncome() {
return Income;
}
public void setIncome(String income) {
Income = income;
}
public String getMarried() {
return Married;
}
public void setMarried(String married) {
Married = married;
}
public String getChildren() {
return Children;
}
public void setChildren(String children) {
Children = children;
}
public String getCar() {
return Car;
}
public void setCar(String car) {
Car = car;
}
public String getSave_Act() {
return Save_Act;
}
public void setSave_Act(String save_Act) {
Save_Act = save_Act;
}
public String getCurrent_Act() {
return Current_Act;
}
public void setCurrent_Act(String current_Act) {
this.Current_Act = current_Act;
}
public String getMortgage() {
return Mortgage;
}
public void setMortgage(String mortgage) {
this.Mortgage = mortgage;
}
public String getPep() {
return Pep;
}
public void setPep(String pep) {
Pep = pep;
}
public String toString() {
return "[ID = " + ", age=";
/// ect....
}
public void processData(List<String[]> content) {
int index = 0;
for (List<String> rowData : content) {
//initialize array of objects
//o[index] = new Client();
//use setters to populate your array of objects
o[index].setID(rowData.get(0));
o[index].setAge(rowData.get(1));
o[index].setRegion(rowData.get(3));
o[index].setSex(rowData.get(2));
o[index].setIncome(rowData.get(4));
o[index].setMarried(rowData.get(5));
o[index].setChildren(rowData.get(6));
o[index].setCar(rowData.get(7));
o[index].setSave_Act(rowData.get(8));
o[index].setCurrent_Act(rowData.get(9));
o[index].setMortgage(rowData.get(10));
o[index].setPep(rowData.get(11));
System.out.println(rowData);
index++;
}
}
public void printData() {
}
}
The problem is in the processData method. The type of content is List<String[]>. So when you try to loop this list, each element is a String array, not List. Also, since each element in your list is a String array, you can access the elements of each of the String Array elements of the list by using the normal array square brackets, instead of get method of List. Try the following fix:
public void processData(List<String[]> content) {
int index=0;
for (String[] rowData: content){
//initialize array of objects
//o[index] = new Client();
//use setters to populate your array of objects
o[index].setID(rowData[0]);
o[index].setAge(rowData[1]);
o[index].setRegion(rowData[3]);
o[index].setSex(rowData[2]);
o[index].setIncome(rowData[4]);
o[index].setMarried(rowData[5]);
o[index].setChildren(rowData[6]);
o[index].setCar(rowData[7]);
o[index].setSave_Act(rowData[8]);
o[index].setCurrent_Act(rowData[9]);
o[index].setMortgage(rowData[10]);
o[index].setPep(rowData[11]);
System.out.println(rowData);
index++;
}
}
As your error hints at... content is a List<String[]>, so it contains String[] elements, not List<String> elements.
If your end goal is a list of Client objects, just make the method List<Client> readData() instead.
List<Client> clients = new ArrayList<Client>();
BufferedReader br = null;
try {
//file reader
br = new BufferedReader(new FileReader(file));
//string to add lines to
String line = "";
Client c = null;
while ((line = br.readLine()) != null) {
c = new Client();
String[] rowData = line.split(",");
c.setID(rowData.get(0));
...
clients.add(c);
}
} catch (FileNotFoundException e) {
e.printStackTrace();
} finally {
try {
if (br != null) br.close();
} catch (Exception e) {}
}
return clients;

parsing multi nested json with GSON

I have to parse the json file into text file, Sample json file as below,
{
"link":"https://xxx.nt",
"liveChannels":[
{
"name":"Sony TV",
"id":1004,
"link":"https://xxx.nt",
"decryptionTicket":"https://xxxy.nt",
"viewLevel":"Too High",
"programs":
{
"totalItems":1,
"programs":[
{
"name":"Live or die",
"id":1000000000,
"catchUp":["FUN"],
"startOver":["Again"]
}
]
}
}
]
}
I have used GSON to parse the file by creating the below java classes.
Channel
LiveChannel
programs
subprograms
Channel.java
public class channel
{
String link = null;
ArrayList<liveChannels> liveChannels;
public String getLink() {
return link;
}
public void setLink(String link) {
this.link = link;
}
public ArrayList<liveChannels> getliveChannels() {
return liveChannels;
}
public void setliveChannels(ArrayList<liveChannels> liveChannels) {
this.liveChannels = liveChannels;
}
}
livechannel.java
public class liveChannels {
String name = null;
int id;
String link = null;
String decryptionTicket = null;
String viewLevel = null;
public void setName(String name) {
this.name = name;
}
public String getName() {
return name;
}
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getLink() {
return link;
}
public void setLink(String link) {
this.link = link;
}
public String getDecryptionTicket() {
return decryptionTicket;
}
public void setDecryptionTicket(String decryptionTicket) {
this.decryptionTicket = decryptionTicket;
}
public String getViewLevel() {
return viewLevel;
}
public void setViewLevel(String viewLevel) {
this.viewLevel = viewLevel;
}
}
After this how to parse the logic from program onwards.
"programs":
{
"totalItems":1,
program.java
public class programs {
ArrayList<sub_programs> sub_programs;
int totalItems;
public int getTotalItems() {
return totalItems;
}
public void setTotalItems(int totalItems) {
this.totalItems = totalItems;
}
public ArrayList<sub_programs> getProgramsDetails() {
return sub_programs;
}
public void setProgramsDetails(ArrayList<sub_programs> sub_programs) {
this.sub_programs = sub_programs;
}
}
sub_program.java
public class sub_programs {
String name = null;
int id;
String catchUp = null;
String startOver = null;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getCatchUp() {
return catchUp;
}
public void setCatchUp(String catchUp) {
this.catchUp = catchUp;
}
public String getStartOver() {
return startOver;
}
public void setStartOver(String startOver) {
this.startOver = startOver;
}
}
and main look like below,
public static void main(String[] args) throws IOException
{
Gson gson = new Gson();
String contents = FileUtils.readFileToString(
new File("C:/sample.json"), "UTF-8");
channel channelHeader = gson.fromJson(contents, channel.class);
System.out.println("Channel Information --->");
System.out.println("Channel Link: " + channelHeader.getLink());
ArrayList<liveChannels> liveChannels = channelHeader.getliveChannels();
for (int i = 0; i < liveChannels.size(); i++) {
System.out.println("liveChannels Detail --->");
liveChannels liveChannelsDetail = liveChannels.get(i);
System.out.println("Channel Name : " + liveChannelsDetail.getName());
System.out.println("Channel ID : " + liveChannelsDetail.getId());
System.out.println("Channel Description Ticket: " + liveChannelsDetail.getDecryptionTicket());
System.out.println("Channel View Level : " + liveChannelsDetail.getViewLevel());
}
}
}
Could anyone please help to get the logic to parse the program from livechannel class onwards.
As programs is not an array list , What else would be an other way around to get the values.
You are missing the programs object in your liveChannels class.
public class liveChannels {
String name = null;
int id;
String link = null;
String decryptionTicket = null;
String viewLevel = null;
programs programs;
public void setPrograms (programs programs) {
this.programs = programs;
}
public programs getPrograms() {
return programs;
}
...
}
And then in your programs class, you will need to rename the sub_programs field to programs
public class programs {
ArrayList<sub_programs> programs;
...
}
As an aside, your class naming does not follow Java standards and is considered bad practice. Your classes should be named as such:
Channel
LiveChannel
Program
SubProgram
Note that this will not affect GSON's ability to parse your documents as GSON cares more about the property name than it does the actual class name of the field.

JSON mapping to Java returning null value

I'm trying to map JSON to Java using gson.I was succesful in writing the logic but unsuccesful in getting the output.Below posted are my JSON and Java files.Any help would be highly appreciated.
This is the output i'm getting
value:null
Below posted is the code for .json files
{
"catitem": {
"id": "1.196289",
"src": "http://feeds.reuters.com/~r/reuters/MostRead/~3/PV-SzW7Pve0/story06.htm",
"orig_item_date": "Tuesday 16 June 2015 07:01:02 PM UTC",
"cat_id": "1",
"heding": "Putin says Russia beefing up nuclear arsenal",
"summary": "KUvdfbefb bngfb",
"body": {
"bpart": [
"KUBINKA,dvdvdvdvgbtgfdnhfbnrtdfbcv dbnfg"
]
}
}
}
Below posted is my .java file
public class offc {
public static void main(String[] args) {
JsonReader jr = null;
try {
jr = new JsonReader(new InputStreamReader(new FileInputStream(
"C:\\Users\\rishii\\IdeaProjects\\rishi\\src\\file3.json")));
} catch (Exception ex) {
ex.printStackTrace();
}
Doll s = new Doll();
Gson g = new Gson();
Doll sr1 = g.fromJson(jr, Doll.class);
System.out.println(sr1);
}
}
Below posted is the code for Doll.java
class Doll {
private catitem ct;
public void setCt(catitem ct) {
this.ct = ct;
}
public catitem getCt() {
return ct;
}
#Override
public String toString()
{
return "value:" + ct;
}
class catitem {
private String id;
private String src;
private String orig_item_date;
private String cat_id;
private String heding;
private String summary;
private body ber;
catitem(String id, String src, String orig_item_date, String cat_id, String heding,
String summary) {
this.id = id;
this.src = src;
this.orig_item_date = orig_item_date;
this.cat_id = cat_id;
this.heding = heding;
this.summary = summary;
}
public void setId(String id) {
this.id = id;
}
public String getId() {
return id;
}
public void setSrc(String src) {
this.src = src;
}
public String getSrc() {
return src;
}
public void setOrig_item_date(String Orig_item_date) {
this.orig_item_date = Orig_item_date;
}
public String getOrig_item_date() {
return getOrig_item_date();
}
public void setCat_id(String cat_id) {
this.cat_id = cat_id;
}
public String getCat_id() {
return cat_id;
}
public void setHeding(String heding) {
this.heding = heding;
}
public String getHeding() {
return heding;
}
public void setSummary(String summary) {
this.summary = summary;
}
public String getSummary() {
return summary;
}
public void setBer(body ber) {
this.ber = ber;
}
public body getBer() {
return ber;
}
#Override
public String toString() {
return "id:" + id + "cat_id" + cat_id + "summary" + summary + "orig_date"
+ orig_item_date + "heding" + heding;
}
}
class body {
private String bpart;
public void setBpart(String r) {
this.bpart = r;
}
public String getBpart() {
return bpart;
}
#Override
public String toString() {
return "hiii";
}
}
}
The issue is in class Doll, You have a field ct but in json catitem. Rename the field ct to catitem or if you are using Gson use #SerializedName("catitem") on filed ct and it will work.

Categories