Home > Software engineering >  How to create a model for pictures from Unsplash?
How to create a model for pictures from Unsplash?

Time:07-23

I need to use the Unsplash API to display a list of pictures that come to me, the title and the author. The problem is that I do not understand how to create a model for converting JSON that comes to me so that I can get the picture, author and title. JSON has nested elements and I don't understand how to do it. How can i do this? My JSON for one picture:

 {
      "id":"RBo6ayiFND0",
      "created_at":"2022-07-08T13:04:40-04:00",
      "updated_at":"2022-07-22T00:20:05-04:00",
      "promoted_at":null,
      "width":4160,
      "height":6240,
      "color":"#c0c0c0",
      "blur_hash":"LPIOLgtR%1IT~qsSMxxZx][email protected]",
      "description":null,
      "alt_description":null,
      "urls":{
         "raw":"https://images.unsplash.com/photo-1657299156528-2d50a9a6a444?ixid=MnwzNDg3MDF8MXwxfGFsbHwxfHx8fHx8Mnx8MTY1ODQ4ODUyOQ\u0026ixlib=rb-1.2.1",
         "full":"https://images.unsplash.com/photo-1657299156528-2d50a9a6a444?crop=entropy\u0026cs=tinysrgb\u0026fm=jpg\u0026ixid=MnwzNDg3MDF8MXwxfGFsbHwxfHx8fHx8Mnx8MTY1ODQ4ODUyOQ\u0026ixlib=rb-1.2.1\u0026q=80",
         "regular":"https://images.unsplash.com/photo-1657299156528-2d50a9a6a444?crop=entropy\u0026cs=tinysrgb\u0026fit=max\u0026fm=jpg\u0026ixid=MnwzNDg3MDF8MXwxfGFsbHwxfHx8fHx8Mnx8MTY1ODQ4ODUyOQ\u0026ixlib=rb-1.2.1\u0026q=80\u0026w=1080",
         "small":"https://images.unsplash.com/photo-1657299156528-2d50a9a6a444?crop=entropy\u0026cs=tinysrgb\u0026fit=max\u0026fm=jpg\u0026ixid=MnwzNDg3MDF8MXwxfGFsbHwxfHx8fHx8Mnx8MTY1ODQ4ODUyOQ\u0026ixlib=rb-1.2.1\u0026q=80\u0026w=400",
         "thumb":"https://images.unsplash.com/photo-1657299156528-2d50a9a6a444?crop=entropy\u0026cs=tinysrgb\u0026fit=max\u0026fm=jpg\u0026ixid=MnwzNDg3MDF8MXwxfGFsbHwxfHx8fHx8Mnx8MTY1ODQ4ODUyOQ\u0026ixlib=rb-1.2.1\u0026q=80\u0026w=200",
         "small_s3":"https://s3.us-west-2.amazonaws.com/images.unsplash.com/small/photo-1657299156528-2d50a9a6a444"
      },
      "links":{
         "self":"https://api.unsplash.com/photos/RBo6ayiFND0",
         "html":"https://unsplash.com/photos/RBo6ayiFND0",
         "download":"https://unsplash.com/photos/RBo6ayiFND0/download?ixid=MnwzNDg3MDF8MXwxfGFsbHwxfHx8fHx8Mnx8MTY1ODQ4ODUyOQ",
         "download_location":"https://api.unsplash.com/photos/RBo6ayiFND0/download?ixid=MnwzNDg3MDF8MXwxfGFsbHwxfHx8fHx8Mnx8MTY1ODQ4ODUyOQ"
      },
      "categories":[
         
      ],
      "likes":21,
      "liked_by_user":false,
      "current_user_collections":[
         
      ],
      "sponsorship":{
         "impression_urls":[
            "https://secure.insightexpressai.com/adServer/adServerESI.aspx?script=false\u0026bannerID=10624831\u0026rnd=[timestamp]\u0026redir=https://secure.insightexpressai.com/adserver/1pixel.gif"
         ],
         "tagline":"Wholesome crispbread from Sweden",
         "tagline_url":"https://www.wasa.com/global/",
         "sponsor":{
            "id":"5tdWPtk6hBg",
            "updated_at":"2022-07-22T06:53:49-04:00",
            "username":"wasacrispbread",
            "name":"Wasa Crispbread",
            "first_name":"Wasa Crispbread",
            "last_name":null,
            "twitter_username":null,
            "portfolio_url":"https://www.wasa.com/global/",
            "bio":"Things we love:\r\n           
  • Related