Questions tagged [moshi]

Moshi is a JSON library for Android and Java. It makes it easy to parse JSON into Java objects:

About

Moshi is a modern JSON library for Android and Java. It makes it easy to parse JSON into Java objects

Moshi has built-in support for reading and writing Java’s core data types:

  • Primitives (int, float, char...) and their boxed counterparts (Integer, Float, Character...).
  • Arrays, Collections, Lists, Sets, and Maps
  • Strings
  • Enums

Links

537 questions
-1
votes
1 answer

How to convert a JSON array of mixed types using moshi and kotlin

Iam unable to convert this Json, keep getting the following error: com.squareup.moshi.JsonDataException: Expected a string but was BEGIN_OBJECT at path {"summary": { "rows": [ [ "08 May, 2023", { "name": "some…
Ekanath
  • 24
  • 4
-1
votes
1 answer

Retrofit android Expected BEGIN_ARRAY but was BEGIN_OBJECT at line 1 column 2 path $

I am new to Retrofit and I am having a weird problem. I am getting the following error --> Expected BEGIN_ARRAY but was BEGIN_OBJECT at line 1 column 2 path $ However when I hit the endpoint with a curl command I get back a json array. EDIT Sorry…
user1743524
  • 655
  • 1
  • 7
  • 14
-1
votes
1 answer

Moshi: Parse NULL value which suppose to be an integer

I have a class like public class Data{ int integer_value = 0; } Then I got json from server {"integer_value":null} When I trying to parse it by String json = "{\"integer_value\":null}" Moshi moshi = new Moshi.Builder().build(); JsonAdapter
Yeung
  • 2,202
  • 2
  • 27
  • 50
-1
votes
1 answer

Loading an image into a RecyclerView cell

override fun onBindViewHolder(holder: CustomViewHolder, position: Int) { val itunesStoreItemTitle = itunes.results.get(position) val imageURL = itunesStoreItemTitle.artworkUrl100 //val inputStream = URL(imageURL).openStream() //val…
software is fun
  • 7,286
  • 18
  • 71
  • 129
-1
votes
1 answer

How to get specific data from API request without creating data classes including other data classes?

for example: { "error": false, "message": "", "code": "", "ver": "v1.0.0", "base": "https://,,,,,,,,,.com/", "count": 1, "updated": "2020-10-28T19:40:51+03:00", "data": [ { "id": "44", "slug": "human-resources", "name": "Human resources", "img1":…
-1
votes
1 answer

Using Moshi to parse the following JSON

I have the following JSON response from an API endpoint. I have tried using GSON to parse the JSON but there seems to be a bug. Now I am trying to see if I can use Moshi. How can I use Moshi to parse the following JSON object:…
George
  • 2,865
  • 6
  • 35
  • 59
-1
votes
1 answer

Android Moshi: what's the development status

I remember Moshi being presented as the upgrade to (Google's) Gson for Android from the creators of Gson themselves (in Square), with better performances and better support for Kotlin. However, the latest release is now almost a year old, and even…
fast3r
  • 1,298
  • 13
  • 15
-2
votes
1 answer

parse No Key json list with moshi in Android

What I am trying to do is to get Json response from GitHub API call of user's repository list. response example from Github is like below. [ { "id": 78688034, "node_id": "MDEwOlJlcG9zaXRvcnk3ODY4ODAzNA==", "name": "py3status", …
foseja
  • 233
  • 2
  • 10
-2
votes
3 answers

Moshi and Retrofit2 : Expected BEGIN_OBJECT but was STRING

I'm facing this issue on my project. I receive from api call a response like: { "aResponse": { "listOfSomething": [ //here some data ] } } And relative data classes are data class ResponseClass( val…
giozh
  • 9,868
  • 30
  • 102
  • 183
-2
votes
1 answer

The import retrofit2.converter cannot be resolved

I am unable to resolve error - The import retrofit2.converter cannot be resolved I am using Eclipse Mars and added following JAR files as External JAR's retrofit-2.1.0.jar moshi-1.2.0.jar it resolves "import retrofit2.Retrofit;" .. but unable to…
Jagdish
  • 231
  • 4
  • 18
-2
votes
1 answer

Moshi JSON parsing

Experimenting with "Moshi" tonight, Square's JSON parsing library. Here's my basic attempt that mirrors an example in their README. I haven't gotten it working no matter what I try! I'd appreciate more eyes/any ideas on it. Moshi moshi = new…
es0329
  • 1,366
  • 1
  • 18
  • 35
-4
votes
3 answers

populate spinner with retrofit and moshi

i am beginner in android dev (both java or kotlin). I am trying to populate spinner from json with retrofit and moshi but I have no idea how to populate it into spinner. to be honest I dont know whether the return of Json data is correct or not,…
Kakashi
  • 3,329
  • 4
  • 26
  • 37
1 2 3
35
36