2017-05-25 73 views
0

當我嘗試訪問arraylist時,出現JsonMappingException,如下所示。我試圖用列表popular_attributes得到它,但它會產生錯誤。任何幫助,將不勝感激。Firebase JsonMappingException

json field

this is the exception

ref.addValueEventListener(new ValueEventListener() { 
     @Override 
     public void onDataChange(DataSnapshot dataSnapshot) { 
      for (DataSnapshot postSnapshot : dataSnapshot.getChildren()) { 
       MyModel model = new MyModel(); 
       Hotel hotel = postSnapshot.getValue(Hotel.class); 
       model.setHotelName(hotel.getName()); 
       model.setHotelImage(hotel.getMain_image()); 
       model.setHotelAdress(hotel.getAdressBooking()); 

       if (hotel.getPopular_attributes() != null) { 
        model.setHotelProperty(hotel.getPopular_attributes()); 
       } 
      }   
     } 

     @Override 
     public void onCancelled(FirebaseError firebaseError) { 

     } 
    }); 
} 
+0

你能顯示你的解析方法嗎? – ashish

+0

我添加了我的解析方法 –

+0

@CanerGulgec請看看如何構建[最小,*完整*可驗證示例](http://stackoverflow.com/help/mcve)。就目前而言,我們無法知道'ref'指向哪個位置,也不知道'Hotel'和'MyModel'類是什麼樣的。但是添加它們可能會使問題時間更長。相反:請閱讀我提供的有關如何提供MCVE的鏈接,因爲這是獲得此類問題幫助的最佳方法。 –

回答

0

添加implement Serializable到你的模型類,並嘗試在List代替使用Map

希望它有幫助。

+0

謝謝我解決了它:) –

相關問題