forked from omni/OmniCards
28 lines
759 B
Kotlin
28 lines
759 B
Kotlin
package ru.omni_devel.cards
|
|
|
|
import kotlinx.serialization.Serializable
|
|
import org.json.JSONArray
|
|
|
|
@Serializable
|
|
class CardIcon(
|
|
val names: LinkedHashMap<String, String>,
|
|
val iconId: String? = null
|
|
) {
|
|
companion object {
|
|
fun parseIconsDataFromJson(json: String): List<CardIcon> {
|
|
val array = JSONArray(json)
|
|
val icons = mutableListOf<CardIcon>()
|
|
|
|
for (i in 0 until array.length()) {
|
|
val obj = array.getJSONObject(i)
|
|
|
|
icons.add(CardIcon(
|
|
names = jsonObjectToMap(obj.getJSONObject("names")),
|
|
iconId = if (obj.has("iconId")) obj.getString("iconId") else null
|
|
))
|
|
}
|
|
|
|
return icons
|
|
}
|
|
}
|
|
} |