https://kotlinlang.org logo
#android
Title
# android
g

g4sarma

08/27/2018, 10:48 AM
But i keep getting getTrendingList onFailure Response java.lang.IllegalStateException: Expected BEGIN_OBJECT but was BEGIN_ARRAY at line 1 column 2 path $
l

louiscad

08/27/2018, 10:52 AM
@g4sarma Missing details there, but my guess is that you're using Moshi, and that it is not really Android related (even if you use it in an Android app). I'd post the question with proper details on StackOverflow, and if you don't get a good answer, post the link in #squarelibraries
m

martin.petrulak

08/27/2018, 11:27 AM
most likely there is an issue with
TrendingRepository
can you post that as well?
g

g4sarma

08/27/2018, 11:31 AM
data class TrendingRepository( val id: Int, val node_id: String, val name: String, val full_name: String, val owner: Owner, val private: Boolean, val html_url: String, val description: String, val fork: Boolean, val url: String, val forks_url: String, val keys_url: String, val collaborators_url: String, val teams_url: String, val hooks_url: String, val issue_events_url: String, val events_url: String, val assignees_url: String, val branches_url: String, val tags_url: String, val blobs_url: String, val git_tags_url: String, val git_refs_url: String, val trees_url: String, val statuses_url: String, val languages_url: String, val stargazers_url: String, val contributors_url: String, val subscribers_url: String, val subscription_url: String, val commits_url: String, val git_commits_url: String, val comments_url: String, val issue_comment_url: String, val contents_url: String, val compare_url: String, val merges_url: String, val archive_url: String, val downloads_url: String, val issues_url: String, val pulls_url: String, val milestones_url: String, val notifications_url: String, val labels_url: String, val releases_url: String, val deployments_url: String, val created_at: String, val updated_at: String, val pushed_at: String, val git_url: String, val ssh_url: String, val clone_url: String, val svn_url: String, val homepage: String, val size: Int, val stargazers_count: Int, val watchers_count: Int, val language: String, val has_issues: Boolean, val has_projects: Boolean, val has_downloads: Boolean, val has_wiki: Boolean, val has_pages: Boolean, val forks_count: Int, val mirror_url: String?, val archived: Boolean, val open_issues_count: Int, val license: License, val forks: Int, val open_issues: Int, val watchers: Int, val default_branch: String, val score: Double )
data class Owner( val login: String, val id: Int, val node_id: String, val avatar_url: String, val gravatar_id: String, val url: String, val html_url: String, val followers_url: String, val following_url: String, val gists_url: String, val starred_url: String, val subscriptions_url: String, val organizations_url: String, val repos_url: String, val events_url: String, val received_events_url: String, val type: String, val site_admin: Boolean )
data class License( val key: String, val name: String, val spdx_id: String, val url: String, val node_id: String )
@martin.petrulak
p

Paul Woitaschek

08/27/2018, 11:34 AM
@g4sarma Just keep removig properties till you find the one causing the issue
👍 1
g

g4sarma

08/27/2018, 11:36 AM
@Paul Woitaschek sounds like a plan
p

Paul Woitaschek

08/27/2018, 11:37 AM
Set a breakpoint to com.squareup.moshi.JsonAdapter to verify the raw data
g

g4sarma

08/27/2018, 11:38 AM
I am not using moshi
b

BMG

08/27/2018, 11:45 AM
Which library are you using to convert JSON to your model? And did you write your adapter class?
r

rkeazor

08/27/2018, 11:56 AM
Not kotlin related. But the error says your Json has a array at the beginning but the way you set up your models, doesnt reflect that. Try putting the json into a json to pojo converter , it probably has a model of a single list
m

martin.petrulak

08/27/2018, 2:09 PM
and what that error is saying that you are putting an array into an object, so just check what properties are arrays in the response and update it
g

g4sarma

08/27/2018, 7:37 PM
@BMG I am using the JSONtoKotlinDataClasss plugin
for android studio
Thank you guys for all your responses but the issue was with the API i resolved it 🙂
2 Views