Skip to content Skip to sidebar Skip to footer

Parsing Nested Json Objects With Gson

I am new to Gson parsing ,did some examples , but this time my json is much complex it looks like this { 'message': 'Ok', 'code': 200, 'data': { 'storage': { '39':

Solution 1:

It is because you have 39 item:

data
   '-storage'-39'-items [item...]

If you change the "39" by "changeIT" for example:

...
"data": {
    "storage": {
        "changeIT": {
            "orderStorageIsAlone": 1,
...

You can use model:

staticclassWrapper{

    Data data;
}

staticclassData{

    Storages storage;
}

staticclassStorages{

    ChangeIT changeIT;
}

staticclassChangeIT{

    List<RItems> items;

    public ChangeIT() {
        items = new ArrayList<>();
    }
}

staticclassRItems{

    String PhotoThumbnail;
    String ItemTitle;
    String showPrice;
    String weight;
    String symbol;
    String created;
    String id;
    String photosPackageRequested;
    String verificationPackageRequested;
    String countryCode;
    ...

(This is an example)

You can not use numbers as Class name, so I don't know how to map a transient element.

Post a Comment for "Parsing Nested Json Objects With Gson"