package com.example.testes import android.util.Log import org.json.JSONArray import org.json.JSONException import org.json.JSONObject data class BooruImage ( var id: String, var tags: String, var url: String, ) { companion object { @Throws(JSONException::class) fun imageFromJson(json: JSONObject): BooruImage { val id = json.getInt("id").toString() val tags = json.getString("tags") val url = json.getString("file_url") return BooruImage(id, tags, url) } @Throws(JSONException::class) fun listFromJsonArray(array: JSONArray): MutableList { val imageList: MutableList = mutableListOf() for (i in 0 until array.length()) { imageList.add(imageFromJson(array.getJSONObject(i))) } return imageList } } }