使用Retrofit 2的android中的Converter Converter问题

时间:2018-10-31 07:06:12

标签: java android retrofit2

我遇到有关“改装”的问题

我正面临“转换器问题”。 我从api成功获取数据,但是在api进行一些更改后,当我从pojo重新生成模型时,我无法获取数据。 当我登录onFailure()时。我遇到转换器问题。需要帮助来解决此问题。

Call<List<FeaturedListingModel>> call = RetrofitClient.getInstance().getApi().getFeaturedListing();
call.enqueue(new Callback<List<FeaturedListingModel>>() {
    @Override
    public void onResponse(Call<List<FeaturedListingModel>> call, Response<List<FeaturedListingModel>> response) {
        List<FeaturedListingModel> data = new ArrayList<>();
        if (response.body() != null && !response.body().isEmpty()) {
            data.addAll(response.body());
            featured_item_view.setAdapter(new featured_listing_adapter(data, featured_listing.this));
        }
    }

    @Override
    public void onFailure(Call<List<FeaturedListingModel>> call, Throwable t) {
        if (t instanceof IOException) {
            Toast.makeText(featured_listing.this, "this is an actual network failure :( inform the user and possibly retry", Toast.LENGTH_SHORT).show();
            // logging probably not necessary
        }
        else {
            Toast.makeText(featured_listing.this, "conversion issue! big problems :(", Toast.LENGTH_SHORT).show();
            // todo log to some central bug tracking service
        }
    }
});

听说我正在调用API响应。

这是来自json响应的数据格式

[{
    "id": 300,
    "author_url": "https:\/\/themographics.com\/wordpress\/doc_api\/clinic\/ambias\/",
    "verified": "on",
    "img_url": "https:\/\/themographics.com\/wordpress\/doc_api\/wp-content\/uploads\/2016\/04\/4-1-270x270.jpg",
    "directory_type": "125",
    "directory_type_name": "clinic",
    "directoty_type_slug": "clinic",
    "directory_type_url": "https:\/\/themographics.com\/wordpress\/doc_api\/provider-category\/clinic\/",
    "name": "Ambias Clinic",
    "address": "White House, Greyhound Ln, South Mimms, Potters Bar, Hertfordshire EN6 3NX, UK",
    "phone": "53 235 856843",
    "fax": "202-555-0137",
    "email": "ambias@themographics.com",
    "website": "www.company.com",
    "category_color": "#3498db",
    "review_data": {
        "reviews": 1,
        "percentage": 100,
        "average_rating": 5,
        "by_ratings": [{
            "rating": 0,
            "total": 0
        }, {
            "rating": 0,
            "total": 0
        }, {
            "rating": 0,
            "total": 0
        }, {
            "rating": 0,
            "total": 0
        }, {
            "rating": 5,
            "total": 1
        }]
    },
    "rating": "5.0",
    "likes": "1",
    "all": {
        "user_type": "professional",
        "full_name": "Ambias Clinic",
        "directory_type": "125",
        "video_url": "<iframe width=\"450\" height=\"300\" src=\"https:\/\/www.youtube.com\/embed\/0aNNYEUARAk\" frameborder=\"0\" webkitallowfullscreen mozallowfullscreen allowfullscreen><\/iframe>",
        "user_gallery": [{
            "thumb": "https:\/\/themographics.com\/wordpress\/doc_api\/wp-content\/uploads\/2016\/04\/img-10-150x150.jpg",
            "full": "https:\/\/themographics.com\/wordpress\/doc_api\/wp-content\/uploads\/2016\/04\/img-10.jpg",
            "id": 212
        }, {
            "thumb": "https:\/\/themographics.com\/wordpress\/doc_api\/wp-content\/uploads\/2016\/04\/img-09-150x150.jpg",
            "full": "https:\/\/themographics.com\/wordpress\/doc_api\/wp-content\/uploads\/2016\/04\/img-09.jpg",
            "id": 211
        }, {
            "thumb": "https:\/\/themographics.com\/wordpress\/doc_api\/wp-content\/uploads\/2016\/04\/img-08-150x150.jpg",
            "full": "https:\/\/themographics.com\/wordpress\/doc_api\/wp-content\/uploads\/2016\/04\/img-08.jpg",
            "id": 210
        }, {
            "thumb": "https:\/\/themographics.com\/wordpress\/doc_api\/wp-content\/uploads\/2016\/04\/img-07-150x150.jpg",
            "full": "https:\/\/themographics.com\/wordpress\/doc_api\/wp-content\/uploads\/2016\/04\/img-07.jpg",
            "id": 209
        }, {
            "thumb": "https:\/\/themographics.com\/wordpress\/doc_api\/wp-content\/uploads\/2016\/04\/img-05-150x150.jpg",
            "full": "https:\/\/themographics.com\/wordpress\/doc_api\/wp-content\/uploads\/2016\/04\/img-05.jpg",
            "id": 207
        }],
        "userprofile_media": "291",
        "facebook": "#",
        "twitter": "#",
        "linkedin": "#",
        "pinterest": "#",
        "google_plus": "#",
        "tumblr": "#",
        "instagram": "#",
        "skype": "ambias",
        "user_address": "White House, Greyhound Ln, South Mimms, Potters Bar, Hertfordshire EN6 3NX, UK",
        "contact_form": "on",
        "profile_status": "active",
        "tagline": "Clinic",
        "phone_number": "53 235 856843",
        "fax": "202-555-0137",
        "languages": ["English", "Arabic", "Danish"],
        "address": "White House, Greyhound Ln, South Mimms, Potters Bar, Hertfordshire EN6 3NX, UK",
        "latitude": "51.693536",
        "longitude": "-0.232837",
        "location": "crawley",
        "zip": "N13",
        "verify_user": "on",
        "privacy": {
            "appointments": "on",
            "phone": "on",
            "email": "on",
            "contact_form": "on"
        },
        "awards": [{
            "name": "Summa Cum Laude, Yale University",
            "date": "2015-04-08",
            "date_formated": "08 Apr, 2015",
            "description": "Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur._x000D_\n"
        }, {
            "name": "Summa Cum Laude, Yale University",
            "date": "2012-09-03",
            "date_formated": "03 Sep, 2012",
            "description": "Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur._x000D_\n"
        }, {
            "name": "Summa Cum Laude, Yale University",
            "date": "2013-08-08",
            "date_formated": "08 Aug, 2013",
            "description": "Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur."
        }],
        "education": [{
            "title": "Bachelor of Medicine, Bachelor of Surgery",
            "institute": "Medical School - New York University",
            "start_date": "2011-01-05",
            "end_date": "2013-01-05",
            "start_date_formated": "Jan,2011",
            "end_date_formated": "Jan,2013",
            "description": "Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur._x000D_"
        }, {
            "title": "Bachelor of Medical Sciences",
            "institute": "Medical School - New York University",
            "start_date": "2013-01-05",
            "end_date": "2014-01-05",
            "start_date_formated": "Jan,2013",
            "end_date_formated": "Jan,2014",
            "description": "Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur._x000D_"
        }, {
            "title": "New York University, Residency in Internal Medicine",
            "institute": "Medical School - New York University",
            "start_date": "2014-01-05",
            "end_date": "2015-01-05",
            "start_date_formated": "Jan,2014",
            "end_date_formated": "Jan,2015",
            "description": "Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur."
        }],
        "experience": [{
            "title": "Lecturer, Department of gastroenterology_x000D_",
            "company": "Co-ed\/Women\/Boys_x000D_",
            "start_date": "2010-05-07_x000D_",
            "end_date": "2012-07-17_x000D_",
            "start_date_formated": "Jan,1970",
            "end_date_formated": "Jan,1970",
            "description": "The Cardiovascular and Respiratory Systems category covers resources concerned with all aspects of cardiovascular and thoracic surgery and respiratory diseases. Topics include circulation, cardiovascular technology and measurement, cardiovascular pharmacology and therapy, hypertension, heart and lung transplantation, arteries, arteriosclerosis, thrombosis, angiology, perfusion, stroke, as well as all types of respiratory and lung diseases._x000D_\n_x000D_"
        }, {
            "title": "Sr Consultant at Gastroentology Hospital_x000D_",
            "company": "Adams State College_x000D_",
            "start_date": "2012-09-22_x000D_",
            "end_date": "2014-08-17_x000D_",
            "start_date_formated": "Jan,1970",
            "end_date_formated": "Jan,1970",
            "description": "The Clinical Immunology &amp; Infectious Diseases category covers resources that focus on basic research in clinical and applied allergy, immunology, and infectious disease. Microbiology and virology resources are included in this category as are resources on HIV, AIDS, sexually transmitted diseases (STDs), and hospital infections._x000D_\n_x000D_"
        }, {
            "title": "Present Consultant, Department of Gastroenterology at Apollo Hospital_x000D_",
            "company": "Florida Hospital College of Health Sciences_x000D_",
            "start_date": "2014-03-27_x000D_",
            "end_date": "2016-08-03_x000D_",
            "start_date_formated": "Jan,1970",
            "end_date_formated": "Jan,1970",
            "description": "Oral Surgery &amp; Medicine resources are concerned with basic, applied, and clinical aspects of oral infections and diseases, including their epidemiology, diagnosis, treatment, and rehabilitation. Specialties such as oral pathology\/biology, oral epidemiology, oral rehabilitation, and oral implants are also included. Facial pain and craniomandibular resources are also covered in this category."
        }],
        "user_profile_specialities": {
            "cardiology-clinic": "Cardiology clinic",
            "children-clinic": "Children clinic",
            "dermatology-clinic": "Dermatology clinic"
        },
        "description": "Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliquat enim ad minim veniam. Eascxcepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt.",
        "first_name": "Ambias",
        "last_name": "Clinic",
        "nickname": "ambias",
        "schedules": {
            "sun_start": "0.875",
            "sun_end": "0.958333333333",
            "mon_start": "0.875",
            "mon_end": "0.958333333333",
            "tue_start": "0.875",
            "tue_end": "0.958333333333",
            "wed_start": "0.875",
            "wed_end": "0.958333333333",
            "thu_start": "0.875",
            "thu_end": "0.958333333333",
            "fri_start": "0.875",
            "fri_end": "0.958333333333",
            "sat_start": "0.875",
            "sat_end": "0.958333333333"
        },
        "professional_statements": "In just three simple steps, DocDirect will help you find your nearest healthcare setting without having to signup. We aim to facilitate you in finding your right doctor with just three clicks without having to ask around or wander to find your nearest healthcare facility.",
        "appointments": "on",
        "phone": "on",
        "email": "on",
        "opening_hours": "on",
        "prices_list": [{
            "title": "BIPOLAR DISORDERS",
            "price": "$225",
            "description": "Oral Surgery &amp; Medicine resources are concerned with basic, applied, and clinical aspects of oral infections and diseases, including thseir epidemiology, diagnosis, treatment, and rehabilitation. Specialties such as oral pathology\/biology, oral epidemiology, oral rehabilitation, and oral implants are also included. Facial pain and craniomandibular resources are also covered in this category."
        }, {
            "title": "Medical\/Surgical Unit",
            "price": "$1500",
            "description": "Oral Surgery &amp; Medicine resources are concerned with basic, applied, and clinical aspects of oral infections and diseases, including their epidemiology, diagnosis, treatment, and rehabilitation. Specialties such as oral pathology\/biology, oral epidemiology, oral rehabilitation, and oral implants are also included. Facial pain and craniomandibular resources are also covered in this category."
        }, {
            "title": "Inpatient Rehabilitation",
            "price": "$1091.44",
            "description": "Oral Surgery &amp; Medicine resources are concerned with basic, applied, and clinical aspects of oral infections and diseases, including their epidemiology, diagnosis, treatment, and rehabilitation. Specialties such as oral pathology\/biology, oral epidemiology, oral rehabilitation, and oral implants are also included. Facial pain and craniomandibular resources are also covered in this category."
        }, {
            "title": "Cesarean Section Delivery",
            "price": "$13182.79",
            "description": "Oral Surgery &amp; Medicine resources are concerned with basic, applied, and clinical aspects of oral infections and diseases, including their epidemiology, diagnosis, treatment, and rehabilitation. Specialties such as oral pathology\/biology, oral epidemiology, oral rehabilitation, and oral implants are also included. Facial pain and craniomandibular resources are also covered in this category."
        }, {
            "title": "Pediatric Evaluation \u2013 Level 1",
            "price": "$387.91",
            "description": "Oral Surgery &amp; Medicine resources are concerned with basic, applied, and clinical aspects of oral infections and diseases, including their epidemiology, diagnosis, treatment, and rehabilitation. Specialties such as oral pathology\/biology, oral epidemiology, oral rehabilitation, and oral implants are also included. Facial pain and craniomandibular resources are also covered in this category."
        }],
        "user_current_package_expiry": "1559779200",
        "user_featured": "1546214400",
        "user_current_package": "34",
        "userprofile_banner": "1204",
        "paypal_enable": "on",
        "paypal_email_id": "wordpress@themographics.com",
        "stripe_enable": "on",
        "stripe_secret": "sk_test_GQmHllLhCKNDNx6f0T2cIfTM",
        "stripe_publishable": "pk_test_v9JXtjELddI4r9unGBShp8TX",
        "stripe_site": "DocDirect Stripe Payment",
        "stripe_decimal": "2",
        "approved_title": "Your Appointment Approved",
        "confirmation_title": "Your Appointment Confirmation",
        "cancelled_title": "Your Appointment Cancelled",
        "thank_you": "Thank you very much for your appointment. We have received your appointment and soon we will let you know regarding your appointment. You will receive a phone call or email regarding to your booking.",
        "schedule_message": "<span style=\"color: #5d5955; font-family: 'Open Sans', Arial, Helvetica, sans-serif;\"><span style=\"font-size: 14px; line-height: 20px;\">Consectetur adipisicing elit sed do eiusmod tempor incididunt ut labore et dolore magna aliqua enim ad minim veniam, <strong>Dr. Jhon Doe<\/strong> nostrud alitaia exercitation ullamco<strong> Invisalign (invisable braces)<\/strong> dolor in reprehenderit.<\/span><\/span>",
        "booking_approved": "Hey %customer_name%!<br\/>\r\n\r\n\t\t\t\t\t\tThis is confirmation that your booking regarding \"%service%\" with %provider% has approved.<br\/>\r\n\t\t\t\t\t\t\r\n\t\t\t\t\t\tWe are waiting you at \"%address%\" on %appointment_date% at %appointment_time%.<br\/><br\/><br\/>\r\n\t\t\t\t\t\t\r\n\t\t\t\t\t\tSincerely,<br\/>\r\n\t\t\t\t\t\t%logo%",
        "booking_confirmed": "Hey %customer_name%!<br\/>\r\n\r\n\t\t\t\t\t\tThis is confirmation that you have booked \"%service%\"<br\/> with %provider%.<br\/>\r\n\t\t\t\t\t\tWe will let your know regarding your booking soon.<br\/><br\/>\r\n\t\t\t\t\t\t\r\n\t\t\t\t\t\tThank you for choosing our company.<br\/><br\/>\r\n\t\t\t\t\t\t\r\n\t\t\t\t\t\tSincerely,<br\/>\r\n\t\t\t\t\t\t%logo%",
        "booking_cancelled": "Hi %customer_name%!<br\/>\r\n\r\n\t\t\t\t\t\t\t This is confirmation that your booking regarding \"%service%\" with %provider% has cancelled.<br\/>\r\n\r\n\t\t\t\t\t\t\t We are very sorry to process your booking right now.<br\/><br\/>\r\n\r\n\t\t\t\t\t\t\t Sincerely,<br\/>\r\n\t\t\t\t\t\t\t %logo%",
        "currency_symbol": "$",
        "currency": "USD",
        "services_cats": {
            "abortion": "Abortion",
            "polyclinic": "Polyclinic",
            "walk-in-clinic": "Walk-in Clinic"
        },
        "wishlist": "",
        "booking_services": {
            "forced-abortion": {
                "title": "Forced abortion",
                "price": "205",
                "category": "abortion"
            },
            "abortion-law": {
                "title": "Abortion law",
                "price": "238",
                "category": "abortion"
            },
            "polyclinic-hospital": {
                "title": "Polyclinic Hospital",
                "price": "150",
                "category": "polyclinic"
            },
            "stuyvesant-polyclinic": {
                "title": "Stuyvesant Polyclinic",
                "price": "350",
                "category": "polyclinic"
            },
            "target-clinic": {
                "title": "Target Clinic",
                "price": "130",
                "category": "walk-in-clinic"
            },
            "careSpot": {
                "title": "CareSpot",
                "price": "785",
                "category": "walk-in-clinic"
            }
        },
        "teams_data": [333, 334, 335, 336, 337, 340]
    }
}]

这是我的FeaturedListingModel

public class FeaturedListingModel implements Serializable {

    @SerializedName("id")
    @Expose
    private Integer id;
    @SerializedName("author_url")
    @Expose
    private String authorUrl;
    @SerializedName("verified")
    @Expose
    private String verified;
    @SerializedName("img_url")
    @Expose
    private String imgUrl;
    @SerializedName("directory_type")
    @Expose
    private String directoryType;
    @SerializedName("directory_type_name")
    @Expose
    private String directoryTypeName;
    @SerializedName("directoty_type_slug")
    @Expose
    private String directotyTypeSlug;
    @SerializedName("directory_type_url")
    @Expose
    private String directoryTypeUrl;
    @SerializedName("name")
    @Expose
    private String name;
    @SerializedName("address")
    @Expose
    private String address;
    @SerializedName("phone")
    @Expose
    private String phone;
    @SerializedName("fax")
    @Expose
    private String fax;
    @SerializedName("email")
    @Expose
    private String email;
    @SerializedName("website")
    @Expose
    private String website;
    @SerializedName("category_color")
    @Expose
    private String categoryColor;
    @SerializedName("review_data")
    @Expose
    private ReviewData reviewData;
    @SerializedName("rating")
    @Expose
    private String rating;
    @SerializedName("likes")
    @Expose
    private String likes;
    @SerializedName("all")
    @Expose
    private All all;

    private boolean isfav;

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public String getAuthorUrl() {
        return authorUrl;
    }

    public void setAuthorUrl(String authorUrl) {
        this.authorUrl = authorUrl;
    }

    public String getVerified() {
        return verified;
    }

    public void setVerified(String verified) {
        this.verified = verified;
    }

    public String getImgUrl() {
        return imgUrl;
    }

    public void setImgUrl(String imgUrl) {
        this.imgUrl = imgUrl;
    }

    public String getDirectoryType() {
        return directoryType;
    }

    public void setDirectoryType(String directoryType) {
        this.directoryType = directoryType;
    }

    public String getDirectoryTypeName() {
        return directoryTypeName;
    }

    public void setDirectoryTypeName(String directoryTypeName) {
        this.directoryTypeName = directoryTypeName;
    }

    public String getDirectotyTypeSlug() {
        return directotyTypeSlug;
    }

    public void setDirectotyTypeSlug(String directotyTypeSlug) {
        this.directotyTypeSlug = directotyTypeSlug;
    }

    public String getDirectoryTypeUrl() {
        return directoryTypeUrl;
    }

    public void setDirectoryTypeUrl(String directoryTypeUrl) {
        this.directoryTypeUrl = directoryTypeUrl;
    }

    public boolean isfav() {
        return isfav;
    }

    public void setIsfav(boolean isfav) {
        this.isfav = isfav;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getAddress() {
        return address;
    }

    public void setAddress(String address) {
        this.address = address;
    }

    public String getPhone() {
        return phone;
    }

    public void setPhone(String phone) {
        this.phone = phone;
    }

    public String getFax() {
        return fax;
    }

    public void setFax(String fax) {
        this.fax = fax;
    }

    public String getEmail() {
        return email;
    }

    public void setEmail(String email) {
        this.email = email;
    }

    public String getWebsite() {
        return website;
    }

    public void setWebsite(String website) {
        this.website = website;
    }

    public String getCategoryColor() {
        return categoryColor;
    }

    public void setCategoryColor(String categoryColor) {
        this.categoryColor = categoryColor;
    }

    public ReviewData getReviewData() {
        return reviewData;
    }

    public void setReviewData(ReviewData reviewData) {
        this.reviewData = reviewData;
    }

    public String getRating() {
        return rating;
    }

    public void setRating(String rating) {
        this.rating = rating;
    }

    public String getLikes() {
        return likes;
    }

    public void setLikes(String likes) {
        this.likes = likes;
    }

    public All getAll() {
        return all;
    }

    public void setAll(All all) {
        this.all = all;
    }

}

0 个答案:

没有答案