android - I am using retrofit2 for networking calls and GSON as a converter to parse JSON. I want to parse a json structure in which keys are not fixed -
i using retrofit2 networking calls , gson converter parse json. want parse json structure in keys not fixed. need in creating models/beans same. here's json trying parse.the keys inside user_card array keep on changing.
{ "isnewversionavailable": false "ishotelslive": true "error": false "message": "card information found." "cardarray": { "status": 1 "msg": "cards fetched succesfully" "user_cards": { "cxb39d6c8bf1b4d5bb6e479fbaca931bb14880e8511": { "name_on_card": "asc" "card_name": "2346" "expiry_year": "2016" "expiry_month": "06" "card_type": "cc" "card_token": "cxb39d6c8bf1b4d5bb6e479fbaca931bb14880e8511" "is_expired": 0 "card_mode": "cc" "card_cvv": 0 "card_no": "512345xxxxxx2346" "card_brand": "mastercard" "card_bin": "512345" "isdomestic": "y" } "re6e69c2482160d8b2190b5dc36af2d46472ba5aafa": { "name_on_card": "asc" "card_name": "1111" "expiry_year": "2016" "expiry_month": "06" "card_type": "cc" "card_token": "re6e69c2482160d8b2190b5dc36af2d46472ba5aafa" "is_expired": 0 "card_mode": "cc" "card_cvv": 0 "card_no": "411111xxxxxx1111" "card_brand": "visa" "card_bin": "411111" "isdomestic": "y" } "tye6977832bc0134be29317af77a6892b3e916dd69e": { "name_on_card": "shoban test" "card_name": "shoban test" "expiry_year": "2017" "expiry_month": "05" "card_type": "cc" "card_token": "tye6977832bc0134be29317af77a6892b3e916dd69e" "is_expired": 0 "card_mode": "cc" "card_cvv": 0 "card_no": "512345xxxxxx2346" "card_brand": "mastercard" "card_bin": "512345" "isdomestic": "y" } "gh57f9e8ee6628e5c1cf1228d8491a08f966cae9f7s": { "name_on_card": "asc" "card_name": "9984" "expiry_year": "2016" "expiry_month": "06" "card_type": "visa" "card_token": "gh57f9e8ee6628e5c1cf1228d8491a08f966cae9f7s" "is_expired": 0 "card_mode": "dc" "card_cvv": 0 "card_no": "434679xxxxxx9984" "card_brand": "visa" "card_bin": "434679" "isdomestic": "y" } } } }
just use map field in cardarray object
import java.util.map; class parent { public boolean isnewversionavailable; public boolean ishotelslive; public boolean error; public string message; public cardarray cardarray; } class cardarray { public int status; public string msg; public map<string, card> user_cards; } class card { public string name_on_card; public string card_name; public string expiry_year; public string expiry_month; public string card_type; public string card_token; public int is_expired; public string card_mode; public string card_cvv; public string card_no; public string card_brand; public string card_bin; public string isdomestic; }
Comments
Post a Comment