Gson ignore json field and deserialize
I'm working with android and gson and i was wondering if i can ignore a field from the webservice.
this its my gson object
Gson gson = new GsonB开发者_JAVA百科uilder().serializeNulls().create();
So what i need is to ignore validator field and deserialize to my custom bean in the following code.
Its any way to do that with gson ?
{ "posts":
[
{
"username": "John",
"message": "I'm back",
"time": "2010-5-6 7:00:34"
"validator":[{
"prog": "Name1",
"name": "Name2",
"computername": "Name3",
"date": "2010-11-20 19:39:55"
}]
}
,
{
"username": "Smith",
"message": "I've been waiting",
"time": "2010-4-6 10:30:26"
"validator":[{
"prog": "Name1",
"name": "Name2",
"computername": "Name3",
"date": "2010-11-20 19:39:55"
}]
}
]}
Thanks in advance
Cheers
You can call gson.fromJson(inputString, localObject)
and if localObject doesn't declare a validator variable, it will just skip it.
精彩评论