• Expected BEGIN_ARRAY but was BEGIN_OBJECT при полученния данных с сервера через Retrofit?

    @Qamrand Автор вопроса
    Юрий, Спасибо вам за Ваш ответ. Я разобрался уже.
  • Expected BEGIN_ARRAY but was BEGIN_OBJECT при полученния данных с сервера через Retrofit?

    @Qamrand Автор вопроса
    Я скорее чего-то не понимаю, но ответ и должен быть List, так как приходят несколько обьектов с json.
    С ретрофита приходят следующие данные:
    I/okhttp.OkHttpClient: {"devices":[{"type":"ATM","latitude":"33.499245","longitude":"51.858686","tw":{"mon":"00:00 - 23:59","tue":"00:00 - 23:59","wed":"00:00 - 23:59","thu":"00:00 - 23:59","fri":"00:00 - 23:59","sat":"00:00 - 23:59","sun":"00:00 - 23:59","hol":"00:00 - 23:59"},"fullAddressRu":"Украина,область Сумская,район Шосткинский,город Шостка,улица Онуприенко,дом 17/","fullAddressUa":"Україна,область Сумська,район Шосткинський,місто Шостка,вулиця Онупрієнка,будинок 17/","fullAddressEn":"Ukraine,area Sumska,district Shostkynskyi,city Shostka,street Onupriienka,building 17/","placeRu":"Магазин","placeUa":"iМагазин","cityRU":"Шостка","cityUA":"Шостка","cityEN":"Shostka"},{"type":"ATM","latitude":"33.468893","longitude":"51.869529","tw":{"mon":"00:00 - 23:59","tue":"00:00 - 23:59","wed":"00:00 - 23:59","thu":"00:00 - 23:59","fri":"00:00 - 23:59","sat":"00:00 - 23:59","sun":"00:00 - 23:59","hol":"00:00 - 23:59"},"fullAddressRu":"Украина,область Сумская,район Шосткинский,город Шостка,улица Карла Маркса,дом 25","fullAddressUa":"Україна,область Сумська,район Шосткинський,місто Шостка,вулиця Карла Маркса,будинок 25","fullAddressEn":"Ukraine,area Sumska,district Shostkynskyi,city Shostka,street Karla Marksa,building 25","placeRu":"Магазин \"Електрон\"","placeUa":"Магазин \"Електрон\"","cityRU":"Шостка","cityUA":"Шостка","cityEN":"Shostka"},{"type":"ATM","latitude":"33.478846","longitude":"51.866308","tw":{"mon":"00:00 - 23:59","tue":"00:00 - 23:59","wed":"00:00 - 23:59","thu":"00:00 - 23:59","fri":"00:00 - 23:59","sat":"00:00 - 23:59","sun":"00:00 - 23:59","hol":"00:00 - 23:59"},"fullAddressRu":"Украина,область Сумская,район Шосткинский,город Шостка,бульвар Садовый,дом 18,корпус А","fullAddressUa":"Україна,область Сумська,район Шосткинський,місто Шостка,бульвар Садовий,будинок 18,корпус А","fullAddressEn":"Ukraine,area Sumska,district Shostkynskyi,city Shostka,boulevard Sadovii,building 18,Housing A","placeRu":"ТЦ \"ПЛЮС\"","placeUa":"ТЦ \"ПЛЮС\"","cityRU":"Шостка","cityUA":"Шостка","cityEN":"Shostka"},{"type":"ATM","latitude":"33.480347","longitude":"51.867227","tw":{"mon":"00:00 - 23:59","tue":"00:00 - 23:59","wed":"00:00 - 23:59","thu":"00:00 - 23:59","fri":"00:00 - 23:59","sat":"00:00 - 23:59","sun":"00:00 - 23:59","hol":"00:00 - 23:59"},"fullAddressRu":"Украина,область Сумская,район Шосткинский,город Шостка,улица Свободы,дом 39,корпус А","fullAddressUa":"Україна,область Сумська,район Шосткинський,місто Шостка,вулиця Свободи,будинок 39,корпус А","fullAddressEn":"Ukraine,area Sumska,district Shostkynskyi,city Shostka,street Svobody,building 39,Housing A","placeRu":"Отделение банка, Зона 24/7","placeUa":"Відділення банку, Зона 24/7","cityRU":"Шостка","cityUA":"Шостка","cityEN":"Shostka"},{"type":"ATM","latitude":"33.529868","longitude":"51.881998","tw":{"mon":"00:00 - 23:59","tue":"00:00 - 23:59","wed":"00:00 - 23:59","thu":"00:00 - 23:59","fri":"00:00 - 23:59","sat":"00:00 - 23:59","sun":"00:00 - 23:59","hol":"00:00 - 23:59"},"fullAddressRu":"Украина,область Сумская,район Шосткинский,город Шостка,улица Куйбышева,дом 41","fullAddressUa":"Україна,область Сумська,район Шосткинський,місто Шостка,вулиця Куйбишева,будинок 41","fullAddressEn":"Ukraine,area Sumska,distr
        орг\"","cityRU":"Шостка","cityUA":"Шостка","cityEN":"Shostka"},{"type":"ATM","latitude":"33.483001","longitude":"51.859016","tw":{"mon":"00:00 - 23:59","tue":"00:00 - 23:59","wed":"00:00 - 23:59","thu":"00:00 - 23:59","fri":"00:00 - 23:59","sat":"00:00 - 23:59","sun":"00:00 - 23:59","hol":"00:00 - 23:59"},"fullAddressRu":"Украина,область Сумская,район Шосткинский,город Шостка,улица Привокзальная,дом 19","fullAddressUa":"Україна,область Сумська,район Шосткинський,місто Шостка,вулиця Привокзальна,будинок 19","fullAddressEn":"Ukraine,area Sumska,district Shostkynskyi,city Shostka,street Pryvokzalna,building 19","placeRu":"ЭКО-МАРКЕТ","placeUa":"ЕКО-МАРКЕТ","cityRU":"Шостка","cityUA":"Шостка","cityEN":"Shostka"},{"type":"ATM","latitude":"33.486500","longitude":"51.864660","tw":{"mon":"00:00 - 23:59","tue":"00:00 - 23:59","wed":"00:00 - 23:59","thu":"00:00 - 23:59","fri":"00:00 - 23:59","sat":"00:00 - 23:59","sun":"00:00 - 23:59","hol":"00:00 - 23:59"},"fullAddressRu":"Украина,область Сумская,район Шосткинский,город Шостка,улица Карла Маркса,дом 40","fullAddressUa":"Україна,область Сумська,район Шосткинський,місто Шостка,вулиця Карла Маркса,будинок 40","fullAddressEn":"Ukraine,area Sumska,district Shostkynskyi,city Shostka,street Karla Marksa,building 40","placeRu":"гостиница \"АНИ\"","placeUa":"готель \"АНІ\"","cityRU":"Шостка","cityUA":"Шостка","cityEN":"Shostka"},{"type":"ATM","latitude":"33.488167","longitude":"51.864226","tw":{"mon":"07:00 - 23:59","tue":"07:00 - 23:59","wed":"07:00 - 23:59","thu":"07:00 - 23:59","fri":"07:00 - 23:59","sat":"07:00 - 23:59","sun":"07:00 - 23:59","hol":"07:00 - 23:59"},"fullAddressRu":"Украина,область Сумская,район Шосткинский,город Шостка,улица Карла Маркса,дом 42","fullAddressUa":"Україна,область Сумська,район Шосткинський,місто Шостка,вулиця Карла Маркса,будинок 42","fullAddressEn":"Ukraine,area Sumska,district Shostkynskyi,city Shostka,street Karla Marksa,building 42","placeRu":"Супермаркет \"Оксана+\"","placeUa":"Супермаркет \"Оксана+\"","cityRU":"Шостка","cityUA":"Шостка","cityEN":"Shostka"},{"type":"ATM","latitude":"33.523680","longitude":"51.885007","tw":{"mon":"00:00 - 23:59","tue":"00:00 - 23:59","wed":"00:00 - 23:59","thu":"00:00 - 23:59","fri":"00:00 - 23:59","sat":"00:00 - 23:59","sun":"00:00 - 23:59","hol":"00:00 - 23:59"},"fullAddressRu":"Украина,область Сумская,район Шосткинский,город Шостка,улица Орджоникидзе,дом 1","fullAddressUa":"Україна,область Сумська,район Шосткинський,місто Шостка,вулиця Орджонікідзе,будинок 1","fullAddressEn":"Ukraine,area Sumska,district Shostkynskyi,city Shostka,street Ordzhonikidze,building 1","placeRu":"магазин Норма","placeUa":"магазин Норма","cityRU":"Шостка","cityUA":"Шостка","cityEN":"Shostka"},{"type":"ATM","latitude":"33.464350","longitude":"51.869620","tw":{"mon":"00:00 - 23:59","tue":"00:00 - 23:59","wed":"00:00 - 23:59","thu":"00......

    Интерфейс:
    Observable<List<AtmData>> getAtmDataByCity(@Url String url);


    Клиент:
    Gson gson = new GsonBuilder()
                        .setLenient()
                        .create();
    
                HttpLoggingInterceptor logging = new HttpLoggingInterceptor();
                logging.setLevel(HttpLoggingInterceptor.Level.BODY);
                OkHttpClient client = new OkHttpClient.Builder()
                        .addInterceptor(logging)
                        .build();
    
                Retrofit retrofit = new Retrofit.Builder()
                        .baseUrl(BASE_URL)
                        .addCallAdapterFactory(RxJava2CallAdapterFactory.create())
                        .addConverterFactory(GsonConverterFactory.create(gson))
                        .client(client)
                        .build();