I have the below json which im serializing
{
"name":"John",
"switch":"1"
},
{
"name":"Jim",
"switch":"0"
}
I want to serialize it to a differnt name So I had to do it like below
class Data {
private String name;
private String flag;
#JsonProperty("flag")
public byte getFlag() {
return flag;
}
#JsonProperty("switch")
public void setSwitch(String s) {
this.flag = flag;
}
}
So that I get it converted as below
{
"name":"John",
"flag":"1"
},
{
"name":"Jim",
"flag":"0"
}
Now I wanted to map the numic values to Y and N for 1 and 0 respectively. Can I acheive that ?
Im expecting my final string to be like this
{
"name":"John",
"switch":"Y"
},
{
"name":"Jim",
"switch":"N"
}
I agree with #Gaƫl J, but still if you want to go ahead this code change might help you to convert that 1/0 to Y/N.
public class Application {
#ToString
static class Input {
#JsonProperty("name")
private String name;
#JsonProperty("switch")
private String flag;
#JsonProperty("name")
public void setName(String name){
this.name = name;
}
#JsonProperty("switch")
public void setSwitch(String s) {
for(SwitchMap valuePair : SwitchMap.values()){
if(valuePair.getValue().equals(s)){
this.flag = valuePair.name();
}
}
}
}
public static void main(String[] args) throws JsonProcessingException {
String json = "{\n" +
"\"name\":\"John\",\n" +
"\"switch\":\"1\"\n" +
"}";
ObjectMapper mapper = new ObjectMapper();
Input in = mapper.readValue(json, Input.class);
System.out.println(mapper.writeValueAsString(in));
}
}
define an enum with the mapping
#Getter
public enum SwitchMap {
Y("1"),
N("0");
private final String value;
private SwitchMap(String value){
this.value = value;
}
}
Related
I want to read this simple JSONfile with java jackson library(I'm new to JSON).
Coud you please tell to me what i do wrong?I created class or JSON object wrongly or this metod of convertion JSON object to Java is wrong, thanks
Edit now i get set of exception like this
This is what the JSONfile stores
{
"id": 15,
"name": "Steve",
"Datax": {
"veek": "vect",
"seev": "vecs"
}
}
And i have three classes
Here is a Cevan:
public class Cevan {
private int id;
private String name;
private Datax data;
public Datax getData() {
return data;
}
public void setData(Datax data) {
this.data = data;
}
public void setName(String name) {
this.name = name;
}
public String getName() {
return name;
}
public void setId(int id) {
this.id = id;
}
public int getId() {
return id;
}
}
and Datax:
public class Datax {
private String veek;
private String seev;
public String getSeev() {
return seev;
}
public String getVeek() {
return veek;
}
public void setSeev(String seev) {
this.seev = seev;
}
public void setVeek(String veek) {
this.veek = veek;
}
}
and Class Main:
public class Main {
public static void main(String[] args) throws IOException {
ObjectMapper mapper=new ObjectMapper();
InputStream is= Cevan.class.getClassLoader().getResourceAsStream("json2.json");
Cevan testObj = mapper.readValue(is, Cevan.class);
}
}
It's like my project looks
Change your resourseStreamReader from
InputStream is=Cevan.class.getResourceAsStream("json2.json");
to:
InputStream is = this.getClassLoader().getResourceAsStream("json2.json");
and also make sure what your json2.json is in classpath
It should be nice to have the log files attached as text and not as image.
The problem should be in the json file.
According to your java classes the json file should be as follows:
{
"id": 15,
"name": "Steve",
"data": {
"veek": "vect",
"seev": "vecs"
}
}
Note the object attribute change from "Datax" to "data".
I want to convert below JSON structure to java object, Annotation bases.
What will be the pojo java class structure?
{
"Data1":{
"Name":"abc",
"Number":2
}
}
Data1 can by any string-like if it coming as data1 first time, next time it can be like "xyz".
How can we convert it using fasterxml json annotations?
class Node {
public String name;
public int number
}
class ConvertedPojo {
public Map<String, Node> attributes;
}
Since Data1 can be any string you need a map which will store all different string as key and value as json object
Class structure will be :
public class Data1{
#JsonProperty("Name")
private String name;
#JsonProperty("Number")
private int number;
public String getName() {
return name;
}
public void setName(String name) {
name = name;
}
public int getNumber() {
return number;
}
public void setNumber(int number) {
number = number;
}
}
public class Data {
#JsonProperty("Data1")
Object data1;
public Object getData1() {
return data1;
}
public void setData1(Object data1) {
this.data1 = data1;
}
}
Take care of the variable naming convention.
Code to test:
public static void main(String[] args) throws JsonProcessingException {
ObjectMapper mapper = new ObjectMapper();
Data data1 = mapper.readValue("{\"Data1\":{\"Name\":\"abc\",\"Number\":2}}", Data.class);
System.out.println(mapper.writeValueAsString(data1));//{"Data1":{"Name":"abc","Number":2}}
Data data2 = mapper.readValue("{\"Data1\":\"data value\"}", Data.class);
System.out.println(mapper.writeValueAsString(data2));//{"Data1":"data value"}
}
I am trying to use Jackson to parse sample json as demonstrated below. However, I the parsing doesn't work (fails without any exceptions - as I get an empty string for event.getAccountId(); What could I be doing wrong?
Thanks!
ObjectMapper om = new ObjectMapper();
String json = "{\"_procurementEvent\" : [{ \"accountId\" : \"3243234\",\"procurementType\" : \"view\"," +
"\"_procurementSubType\" : \"Standard Connector\",\"_quantity\" : \"4\", \"_pricePerMonth\" : \"100.00\"" +
",\"_annualPrice\" : \"1200.00\"}]}";
ProcurementEvent event = om.readValue(json, ProcurementEvent.class);
event.getAccountId(); // returns null
#JsonIgnoreProperties(ignoreUnknown = true)
private static class ProcurementEvent {
private String _accountId;
private String _procurementType;
private String _quantity;
private String _pricePerMonth;
private String _annualPrice;
#JsonProperty("accountId")
public String getAccountId() {
return _accountId;
}
public void setAccountId(String accountId) {
_accountId = accountId;
}
#JsonProperty("procurementType")
public String getProcurementType() {
return _procurementType;
}
public void setProcurementType(String procurementType) {
_procurementType = procurementType;
}
#JsonProperty("_quantity")
public String getQuantity() {
return _quantity;
}
public void setQuantity(String quantity) {
_quantity = quantity;
}
#JsonProperty("_pricePerMonth")
public String getPricePerMonth() {
return _pricePerMonth;
}
public void setPricePerMonth(String pricePerMonth) {
_pricePerMonth = pricePerMonth;
}
#JsonProperty("_annualPrice")
public String getAnnualPrice() {
return _annualPrice;
}
public void setAnnualPrice(String annualPrice) {
_annualPrice = annualPrice;
}
}
In the question, try the following approach:
class ProcurementEvents {
private List<ProcurementEvent> _procurementEvent; // + annotations like #JsonIgnoreProperties, getters/ setters, etc.
}
// json from your example
ProcurementEvents events = om.readValue(json, ProcurementEvents.class);
events.get(0).getAccountId();
I'm working on a project where I'm integrating with a 3rd party service that returns a JSON response. I am using Jackson to deserialize the response into a Java POJO. The response is an object that has a few simple fields that Jackson is able to easily parse. However the response also contains an array with a single entry that is also an object. When Jackson attempts to deserialize it I get the top level object containing a list with the single entry in the list, however all of the fields for the single entry in the list are null. Any idea what I'm doing wrong here?
UPDATE: after setting FAIL_ON_UNKNOWN_PROPERTIES to true, I am getting the following stack trace. Still not sure why it is having issues with the wrapped "RecurringDetail" object in the array.
com.fasterxml.jackson.databind.exc.UnrecognizedPropertyException: Unrecognized field "RecurringDetail" (class com.adyen.www.models.RecurringDetail), not marked as ignorable (19 known properties: "variant", "contractTypes", "tokenDetails", "aliasType", "name", "creationDate", "firstPspReference", "elv", "card", "additionalData", "shopperName", "socialSecurityNumber", "billingAddress", "bank", "recurringDetailReference", "paymentMethodVariant", "alias", "acquirer", "acquirerAccount"])
at [Source: response.json; line: 5, column: 33] (through reference chain: com.adyen.www.models.RecurringDetailsResult["details"]->java.util.ArrayList[0]->com.adyen.www.models.RecurringDetail["RecurringDetail"])
at com.fasterxml.jackson.databind.exc.UnrecognizedPropertyException.from(UnrecognizedPropertyException.java:62)
at com.fasterxml.jackson.databind.DeserializationContext.handleUnknownProperty(DeserializationContext.java:834)
at com.fasterxml.jackson.databind.deser.std.StdDeserializer.handleUnknownProperty(StdDeserializer.java:1094)
at com.fasterxml.jackson.databind.deser.BeanDeserializerBase.handleUnknownProperty(BeanDeserializerBase.java:1470)
at com.fasterxml.jackson.databind.deser.BeanDeserializerBase.handleUnknownVanilla(BeanDeserializerBase.java:1448)
at com.fasterxml.jackson.databind.deser.BeanDeserializer.vanillaDeserialize(BeanDeserializer.java:282)
at com.fasterxml.jackson.databind.deser.BeanDeserializer.deserialize(BeanDeserializer.java:140)
at com.fasterxml.jackson.databind.deser.std.CollectionDeserializer.deserialize(CollectionDeserializer.java:287)
at com.fasterxml.jackson.databind.deser.std.CollectionDeserializer.deserialize(CollectionDeserializer.java:259)
at com.fasterxml.jackson.databind.deser.std.CollectionDeserializer.deserialize(CollectionDeserializer.java:26)
at com.fasterxml.jackson.databind.deser.SettableBeanProperty.deserialize(SettableBeanProperty.java:499)
at com.fasterxml.jackson.databind.deser.impl.MethodProperty.deserializeAndSet(MethodProperty.java:101)
at com.fasterxml.jackson.databind.deser.BeanDeserializer.vanillaDeserialize(BeanDeserializer.java:276)
at com.fasterxml.jackson.databind.deser.BeanDeserializer.deserialize(BeanDeserializer.java:140)
at com.fasterxml.jackson.databind.ObjectMapper._readMapAndClose(ObjectMapper.java:3798)
at com.fasterxml.jackson.databind.ObjectMapper.readValue(ObjectMapper.java:2759)
JSON
{
"creationDate": "2017-01-26T23:11:20+01:00",
"details": [
{
"RecurringDetail": {
"acquirer": "TestPmmAcquirer",
"acquirerAccount": "TestPmmAcquirerAccount",
"additionalData": {
"cardBin": "440000"
},
"alias": "B133243153928547",
"aliasType": "Default",
"card": {
"expiryMonth": "8",
"expiryYear": "2018",
"holderName": "Steve HAll",
"number": "0008"
},
"contractTypes": [
"RECURRING"
],
"creationDate": "2017-01-26T23:11:20+01:00",
"firstPspReference": "8524854686798738",
"paymentMethodVariant": "visadebit",
"recurringDetailReference": "8414854686802111",
"variant": "visa"
}
}
],
"invalidOneclickContracts": "false",
"lastKnownShopperEmail": "someones#email.com",
"shopperReference": "xggZcGauSSG5jP+akIlijQ=="
}
Unit Test
public class RecurringDetailResultTest {
public static ObjectMapper mapper = new ObjectMapper()
{
private static final long serialVersionUID = -174113593500315394L;
{
configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
configure(DeserializationFeature.UNWRAP_SINGLE_VALUE_ARRAYS, true);
setSerializationInclusion(JsonInclude.Include.NON_NULL);
}
};
#Test
public void testParseRecurringDetailResulte() throws IOException {
RecurringDetailsResult result = mapper.readValue(new File("response.json"), new TypeReference<RecurringDetailsResult>(){});
if (result.getDetails() != null && !result.getDetails().isEmpty()) {
RecurringDetail detail = result.getDetails().get(0);
if (StringUtils.isEmpty(detail.getRecurringDetailReference())) {
fail("Recurring detail does not contain any information.");
}
} else {
fail("No result details returned.");
}
}
}
Model (Root object)
public class RecurringDetailsResult
implements java.io.Serializable {
private static final long serialVersionUID = 5297684963950973136L;
private Date creationDate;
private String shopperReference;
private List<RecurringDetail> details;
private String lastKnownShopperEmail;
#JsonGetter("creationDate")
public Date getCreationDate ( ) {
return this.creationDate;
}
#JsonSetter("creationDate")
public void setCreationDate (Date value) {
this.creationDate = value;
}
#JsonGetter("shopperReference")
public String getShopperReference ( ) {
return this.shopperReference;
}
#JsonSetter("shopperReference")
public void setShopperReference (String value) {
this.shopperReference = value;
}
#JsonGetter("details")
public List<RecurringDetail> getDetails ( ) {
return this.details;
}
#JsonSetter("details")
public void setDetails (List<RecurringDetail> value) {
this.details = value;
}
#JsonGetter("lastKnownShopperEmail")
public String getLastKnownShopperEmail ( ) {
return this.lastKnownShopperEmail;
}
#JsonSetter("lastKnownShopperEmail")
public void setLastKnownShopperEmail (String value) {
this.lastKnownShopperEmail = value;
}
}
Model (the object in the array, all of the fields of this guy are null when Jackson deserializes the JSON)
public class RecurringDetail
implements java.io.Serializable {
private static final long serialVersionUID = 5302883242997268343L;
private String name;
private Date creationDate;
private Card card;
private ELV elv;
private Address billingAddress;
private String additionalData;
private Name shopperName;
private String socialSecurityNumber;
private String recurringDetailReference;
private BankAccount bank;
private String alias;
private String aliasType;
private TokenDetails tokenDetails;
private String variant;
private String paymentMethodVariant;
private String firstPspReference;
private List<String> contractTypes;
private String acquirer;
private String acquirerAccount;
#JsonGetter("name")
public String getName ( ) {
return this.name;
}
#JsonSetter("name")
public void setName (String value) {
this.name = value;
}
#JsonGetter("creationDate")
public Date getCreationDate ( ) {
return this.creationDate;
}
#JsonSetter("creationDate")
public void setCreationDate (Date value) {
this.creationDate = value;
}
#JsonGetter("card")
public Card getCard ( ) {
return this.card;
}
#JsonSetter("card")
public void setCard (Card value) {
this.card = value;
}
#JsonGetter("elv")
public ELV getElv ( ) {
return this.elv;
}
#JsonSetter("elv")
public void setElv (ELV value) {
this.elv = value;
}
#JsonGetter("billingAddress")
public Address getBillingAddress ( ) {
return this.billingAddress;
}
#JsonSetter("billingAddress")
public void setBillingAddress (Address value) {
this.billingAddress = value;
}
#JsonGetter("additionalData")
public String getAdditionalData ( ) {
return this.additionalData;
}
#JsonSetter("additionalData")
public void setAdditionalData (String value) {
this.additionalData = value;
}
#JsonGetter("shopperName")
public Name getShopperName ( ) {
return this.shopperName;
}
#JsonSetter("shopperName")
public void setShopperName (Name value) {
this.shopperName = value;
}
#JsonGetter("socialSecurityNumber")
public String getSocialSecurityNumber ( ) {
return this.socialSecurityNumber;
}
#JsonSetter("socialSecurityNumber")
public void setSocialSecurityNumber (String value) {
this.socialSecurityNumber = value;
}
#JsonGetter("recurringDetailReference")
public String getRecurringDetailReference ( ) {
return this.recurringDetailReference;
}
#JsonSetter("recurringDetailReference")
public void setRecurringDetailReference (String value) {
this.recurringDetailReference = value;
}
#JsonGetter("bank")
public BankAccount getBank ( ) {
return this.bank;
}
#JsonSetter("bank")
public void setBank (BankAccount value) {
this.bank = value;
}
#JsonGetter("alias")
public String getAlias ( ) {
return this.alias;
}
#JsonSetter("alias")
public void setAlias (String value) {
this.alias = value;
}
#JsonGetter("aliasType")
public String getAliasType ( ) {
return this.aliasType;
}
#JsonSetter("aliasType")
public void setAliasType (String value) {
this.aliasType = value;
}
#JsonGetter("tokenDetails")
public TokenDetails getTokenDetails ( ) {
return this.tokenDetails;
}
#JsonSetter("tokenDetails")
public void setTokenDetails (TokenDetails value) {
this.tokenDetails = value;
}
#JsonGetter("variant")
public String getVariant ( ) {
return this.variant;
}
#JsonSetter("variant")
public void setVariant (String value) {
this.variant = value;
}
#JsonGetter("paymentMethodVariant")
public String getPaymentMethodVariant ( ) {
return this.paymentMethodVariant;
}
#JsonSetter("paymentMethodVariant")
public void setPaymentMethodVariant (String value) {
this.paymentMethodVariant = value;
}
#JsonGetter("firstPspReference")
public String getFirstPspReference ( ) {
return this.firstPspReference;
}
#JsonSetter("firstPspReference")
public void setFirstPspReference (String value) {
this.firstPspReference = value;
}
#JsonGetter("contractTypes")
public List<String> getContractTypes ( ) {
return this.contractTypes;
}
#JsonSetter("contractTypes")
public void setContractTypes (List<String> value) {
this.contractTypes = value;
}
#JsonGetter("acquirer")
public String getAcquirer ( ) {
return this.acquirer;
}
#JsonSetter("acquirer")
public void setAcquirer (String value) {
this.acquirer = value;
}
#JsonGetter("acquirerAccount")
public String getAcquirerAccount ( ) {
return this.acquirerAccount;
}
#JsonSetter("acquirerAccount")
public void setAcquirerAccount (String value) {
this.acquirerAccount = value;
}
}
The easiest thing I can think to do is to make your java objects look like your Json. Because this Json has a wrapped inner object but not the outer object you would have to have a similar wrapping in java. It isn't elegant but works.
public class RecurringDetailsResult implements java.io.Serializable {
private Date creationDate;
private String shopperReference;
private List<RecurringDetailWrapper> details;
private String lastKnownShopperEmail;
// getters and setters here. No need for any #JsonGetter or #JsonSetter annotations
}
#JsonRootName("RecurringDetail")
public class RecurringDetailWrapper {
#JsonProperty("RecurringDetail")
RecurringDetail recurringDetail;
public RecurringDetail getRecurringDetail() {
return recurringDetail;
}
public void setRecurringDetail(RecurringDetail recurringDetail) {
this.recurringDetail = recurringDetail;
}
}
public class RecurringDetail implements java.io.Serializable {
private static final long serialVersionUID = 5302883242997268343L;
private String name;
private Date creationDate;
private Card card;
private AdditionalData additionalData;
private String socialSecurityNumber;
private String recurringDetailReference;
private String alias;
private String aliasType;
private String variant;
private String paymentMethodVariant;
private String firstPspReference;
private List<String> contractTypes;
private String acquirer;
private String acquirerAccount;
public class AdditionalData {
String cardBin;
public String getCardBin() {
return cardBin;
}
public void setCardBin(String cardBin) {
this.cardBin = cardBin;
}
}
// getters and setters here. No need for any #JsonGetter or #JsonSetter annotations
}
Then in your unit test:
#Test
public void testParseRecurringDetailResulte() throws IOException {
InputStream inputStream = this.getClass().getClassLoader().getResourceAsStream("ID41901838.json");
ObjectReader objectReader = mapper.readerFor(RecurringDetailsResult.class);
RecurringDetailsResult result = objectReader.readValue(inputStream);
if (result.getDetails() != null && !result.getDetails().isEmpty()) {
RecurringDetailWrapper detail = result.getDetails().get(0);
if (StringUtils.isEmpty(detail.getRecurringDetail().getRecurringDetailReference())) {
fail("Recurring detail does not contain any information.");
}
} else {
fail("No result details returned.");
}
}
I posted the full working code here:
https://github.com/teacurran/java-experiments/tree/master/stackoverflow-sandbox/src/main/java/com/wirelust/stackoverflowsandbox/ID41901838
It seems your current structure will work for the response JSON as below (an extra named layer is removed)
{
"creationDate": "2017-01-26T23:11:20+01:00",
"details": [
{
"acquirer": "TestPmmAcquirer",
"acquirerAccount": "TestPmmAcquirerAccount",
"additionalData": {
"cardBin": "440000"
},
"alias": "B133243153928547",
"aliasType": "Default",
"card": {
"expiryMonth": "8",
"expiryYear": "2018",
"holderName": "Steve HAll",
"number": "0008"
},
"contractTypes": [
"RECURRING"
],
"creationDate": "2017-01-26T23:11:20+01:00",
"firstPspReference": "8524854686798738",
"paymentMethodVariant": "visadebit",
"recurringDetailReference": "8414854686802111",
"variant": "visa"
}
],
"invalidOneclickContracts": "false",
"lastKnownShopperEmail": "someones#email.com",
"shopperReference": "xggZcGauSSG5jP+akIlijQ=="
}
For named object maybe you can try something like
public class RecurringDetailsResult
implements java.io.Serializable {
private static final long serialVersionUID = 5297684963950973136L;
private Date creationDate;
private String shopperReference;
private List<Map<String,RecurringDetail>> details;
private String lastKnownShopperEmail;
#JsonGetter("creationDate")
public Date getCreationDate ( ) {
return this.creationDate;
}
#JsonSetter("creationDate")
public void setCreationDate (Date value) {
this.creationDate = value;
}
#JsonGetter("shopperReference")
public String getShopperReference ( ) {
return this.shopperReference;
}
#JsonSetter("shopperReference")
public void setShopperReference (String value) {
this.shopperReference = value;
}
#JsonGetter("details")
public List<Map<String, RecurringDetail>> getDetails ( ) {
return this.details;
}
#JsonSetter("details")
public void setDetails (List<Map<String, RecurringDetail>> value) {
this.details = value;
}
#JsonGetter("lastKnownShopperEmail")
public String getLastKnownShopperEmail ( ) {
return this.lastKnownShopperEmail;
}
#JsonSetter("lastKnownShopperEmail")
public void setLastKnownShopperEmail (String value) {
this.lastKnownShopperEmail = value;
}
}
Given I have the following json:
{
"Company": {
"name": "cookieltd",
"type": "food",
"franchise_location": [
{
"location_type": "town",
"address_1": "5street"
},
{
"location_type": "village",
"address_1": "2road"
}
]
}
}
How can it be binded to the following object classes using Jackson?:
1) Company class
public class Company
{
String name, type;
List<Location> franchise_location = new ArrayList<Location>();
[getters and setters]
}
2) Location class
public class Location
{
String location_type, address_1;
[getters and setters]
}
I have done:
String content = [json above];
ObjectReader reader = mapper.reader(Company.class).withRootName("Company"); //read after the root name
Company company = reader.readValue(content);
but I am getting:
com.fasterxml.jackson.databind.exc.UnrecognizedPropertyException: Unrecognized field "franchise_location"
As far as I can tell, you are simply missing an appropriately named getter for the field franchise_location. It should be
public List<Location> getFranchise_location() {
return franchise_location;
}
(and the setter)
public void setFranchise_location(List<Location> franchise_location) {
this.franchise_location = franchise_location;
}
Alternatively, you can annotate your current getter or field with
#JsonProperty("franchise_location")
private List<Location> franchiseLocation = ...;
which helps to map JSON element names that don't really work with Java field name conventions.
The following works for me
public static void main(String[] args) throws Exception {
String json = "{ \"Company\": { \"name\": \"cookieltd\", \"type\": \"food\", \"franchise_location\": [ { \"location_type\": \"town\", \"address_1\": \"5street\" }, { \"location_type\": \"village\", \"address_1\": \"2road\" } ] } }";
ObjectMapper mapper = new ObjectMapper();
ObjectReader reader = mapper.reader(Company.class).withRootName(
"Company"); // read after the root name
Company company = reader.readValue(json);
System.out.println(company.getFranchise_location().get(0).getAddress_1());
}
public static class Company {
private String name;
private String type;
private List<Location> franchise_location = new ArrayList<Location>();
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
public List<Location> getFranchise_location() {
return franchise_location;
}
public void setFranchise_location(List<Location> franchise_location) {
this.franchise_location = franchise_location;
}
}
public static class Location {
private String location_type;
private String address_1;
public String getLocation_type() {
return location_type;
}
public void setLocation_type(String location_type) {
this.location_type = location_type;
}
public String getAddress_1() {
return address_1;
}
public void setAddress_1(String address_1) {
this.address_1 = address_1;
}
}
and prints
5street
my solution for JSON is always GSON, you can do some research on that, as long as you have the correct structure of class according to the JSON, it can automatically transfer from JSON to object:
Company company = gson.fromJson(json, Company.class);
GSON is so smart to do the convertion thing!
enjoy GSON !