Home > other >  How to make model class for this json data
How to make model class for this json data

Time:08-04

Please help me to make model for this json, facing issue in entry array, unable to make model for this entry array in the json data, kindly help me to get rid of this issue:

{
  "feed": {
    "entry": [
      {
        "im:name": {
          "label": "EquityValueMeasure"
        },
        "rights": {
          "label": "© FIRST SEAFRONT FINANCIAL LIMITED"
        },
        "im:price": {
          "label": "Get",
          "attributes": {
            "amount": "0.00",
            "currency": "USD"
          }
        },
        "im:image": [
          {
            "label": "https://is5-ssl.mzstatic.com/image/thumb/Purple112/v4/87/75/e5/8775e570-34fb-5762-3885-1a1c57eb09ea/AppIcon-0-0-1x_U007emarketing-0-0-0-5-0-0-sRGB-0-0-0-GLES2_U002c0-512MB-85-220-0-0.png/53x53bb.png",
            "attributes": {
              "height": "53"
            }
          },
          {
            "label": "https://is1-ssl.mzstatic.com/image/thumb/Purple112/v4/87/75/e5/8775e570-34fb-5762-3885-1a1c57eb09ea/AppIcon-0-0-1x_U007emarketing-0-0-0-5-0-0-sRGB-0-0-0-GLES2_U002c0-512MB-85-220-0-0.png/75x75bb.png",
            "attributes": {
              "height": "75"
            }
          },
          {
            "label": "https://is3-ssl.mzstatic.com/image/thumb/Purple112/v4/87/75/e5/8775e570-34fb-5762-3885-1a1c57eb09ea/AppIcon-0-0-1x_U007emarketing-0-0-0-5-0-0-sRGB-0-0-0-GLES2_U002c0-512MB-85-220-0-0.png/100x100bb.png",
            "attributes": {
              "height": "100"
            }
          }
        ],
        "im:artist": {
          "label": "FIRST SEAFRONT FINANCIAL LIMITED",
          "attributes": {
            "href": "https://apps.apple.com/us/developer/first-seafront-financial-limited/id1637564433?uo=2"
          }
        },
        "title": {
          "label": "EquityValueMeasure - FIRST SEAFRONT FINANCIAL LIMITED"
        },
        "link": {
          "attributes": {
            "rel": "alternate",
            "type": "text/html",
            "href": "https://apps.apple.com/us/app/equityvaluemeasure/id1637564431?uo=2"
          }
        },
        "id": {
          "label": "https://apps.apple.com/us/app/equityvaluemeasure/id1637564431?uo=2",
          "attributes": {
            "im:id": "1637564431",
            "im:bundleId": "Huta.Naguanzuomaca"
          }
        },
        "im:contentType": {
          "attributes": {
            "term": "Application",
            "label": "Application"
          }
        },
        "category": {
          "attributes": {
            "im:id": "6002",
            "term": "Utilities",
            "scheme": "https://apps.apple.com/us/genre/ios-utilities/id6002?uo=2",
            "label": "Utilities"
          }
        },
        "im:releaseDate": {
          "label": "2022-08-02T02:17:49-07:00",
          "attributes": {
            "label": "August 2, 2022"
          }
        }
      }
      ]
      
  }
}

Please help me to make model for this json, facing issue in entry array, unable to make model for this entry array in the json data, kindly help me to get rid of this issue: Hoping I will get support asap.

Thank you.

CodePudding user response:

You can try this or any other online tool https://json2kt.com/

Hope it helps.

Ankit

CodePudding user response:

Here. This might help you. Thank you.

package modelClass

import com.beust.klaxon.*

private val klaxon = Klaxon()

data class Model (
val feed: Feed
) {
public fun toJson() = klaxon.toJsonString(this)

companion object {
    public fun fromJson(json: String) = klaxon.parse<Model>(json)
    }
}

data class Feed (
    val entry: List<Entry>
)

data class Entry (
   @Json(name = "im:name")
   val imName: IMName,

   val rights: IMName,

   @Json(name = "im:price")
   val imPrice: IMPrice,

   @Json(name = "im:image")
   val imImage: List<IMImage>,

   @Json(name = "im:artist")
   val imArtist: IMArtist,

   val title: IMName,
   val link: Link,
   val id: ID,

   @Json(name = "im:contentType")
   val imContentType: IMContentType,

   val category: Category,

   @Json(name = "im:releaseDate")
   val imReleaseDate: IMReleaseDate
)

  data class Category (
   val attributes: CategoryAttributes
 )

  data class CategoryAttributes (
     @Json(name = "im:id")
     val imID: String,

     val term: String,
     val scheme: String,
     val label: String
   )

   data class ID (
      val label: String,
      val attributes: IDAttributes
   )

   data class IDAttributes (
     @Json(name = "im:id")
     val imID: String,

     @Json(name = "im:bundleId")
     val imBundleID: String
    )

   data class IMArtist (
     val label: String,
     val attributes: IMArtistAttributes
   )

    data class IMArtistAttributes (
      val href: String
     )

   data class IMContentType (
       val attributes: IMContentTypeAttributes
      )

      data class IMContentTypeAttributes (
      val term: String,
      val label: String
     )

data class IMImage (
val label: String,
val attributes: IMImageAttributes
)

data class IMImageAttributes (
val height: String
 )

data class IMName (
val label: String
)

data class IMPrice (
val label: String,
val attributes: IMPriceAttributes
)

data class IMPriceAttributes (
val amount: String,
val currency: String
)

data class IMReleaseDate (
val label: String,
val attributes: IMName
)

data class Link (
val attributes: LinkAttributes
)

data class LinkAttributes (
val rel: String,
val type: String,
val href: String
)
  • Related