Fetch list of transactions from json

In my task I need to fetch some data.

I made UserModelClass where I put some data classes:

      "id": "1",
      "IBAN": "HR123456789012345678901",
      "amount": "2.523,00",
      "currency": "HRK",
      "transactions": [
        {
          "id": "1",
          "date": "25.01.2016.",
          "description": "Uplata 1",
          "amount": "15,00 HRK"
        },
        {
          "id": "2",
          "date": "17.02.2016.",
          "description": "Uplata 2",
          "amount": "50,00 HRK",
          "type": "GSM VOUCHER"
        }]

This is my code:

data class UserModelClass (
    val user_id:String,
    val accounts: List<AccountsList>
)

data class AccountsList(
    val id: String,
    val IBAN: String,
    val amount: String,
    val currency: String,
    val transactions: List<transactionsList>

)

data class transactionsList(
    val id: String,
    val date: String,
    val description: String,
    val amount: String
    //
)

Problem is that some transactions have type and some don't have it. I tried to make one more data class transactionsList where I put val type but there can be only one data class with the same name.



from Recent Questions - Stack Overflow https://ift.tt/3HZJdr1
https://ift.tt/eA8V8J

Comments

Popular posts from this blog

Today Walkin 14th-Sept

Hibernate Search - Elasticsearch with JSON manipulation

Spring Elasticsearch Operations