2016-04-14 32 views
0

Bu JSON ayrıştırma ediyorum:Tarihi JSON Ayrıştırma formu

{ 
"poster_path":"\/vZpB8ezB1IqpxI9rx553TuGwDzJ.jpg", 
"overview":"Thirty years after defeating the Galactic Empire, Han Solo and his allies face a new threat from the evil Kylo Ren and his army of Stormtroopers.", 
"release_date":"2015-12-15", 
"genre_ids":[ ], 
"id":140607, 
"original_title":"Star Wars: The Force Awakens", 
"original_language":"en", 
"title":"Star Wars: The Force Awakens", 
"vote_average":7.65 
} 

ve ben

overview=movieForecast.getString(OVERVIEW); 
original_title = movieForecast.getString(ORIGINAL_TITLE); 
movie_poster= movieForecast.getString(POSTER_PATH); 
user_rating = movieForecast.getDouble(VOTE_AVERAGE); 
release_date = movieForecast.getInt(RELEASE_DATE); 

istediğiniz tüm özelliklerini ayrıştırmak olabilir ama user_rating ve çıkış tarihi ile ilgili bir sorun vardı ama GetDouble

ürününü deitirerek user_rating yazilimina düzeltebilirdim ama ayni tarihte onunla birsey yapamam (getDouble, getInteger, getString) hiçbirsey yapamam!

+1

'dize RELEASE_DATE = movieForecast.getString ("RELEASE_DATE"); 'çalışmıyor? –

cevap

1

Sürümünüzün bir Date nesnesi olup olmadığını bilmiyorum. Olduysa, SimpleDateFormatter'u kullanabilirsiniz.


String date = movieForecast.getString("release_date"); 
SimpleDateFormatter sdf = new SimpleDateFormatter("yyyy-mm-dd"); 
Date releaseDate = sdf.parse(date); 

movieForecast.setDate(releaseDate); //example