mirror of
https://github.com/YTVanced/VancedManager
synced 2024-11-15 23:35:06 +00:00
commit
5681b6fb4f
1 changed files with 17 additions and 2 deletions
|
@ -12,10 +12,25 @@ import kotlinx.coroutines.withContext
|
|||
|
||||
object JsonHelper {
|
||||
|
||||
suspend fun getJson(url: String): JsonObject =
|
||||
var dataMap: HashMap<String, JsonObject> = HashMap()
|
||||
|
||||
suspend fun getJson(url: String): JsonObject
|
||||
{
|
||||
if(dataMap.containsKey(url))
|
||||
{
|
||||
return dataMap[url]!!
|
||||
}
|
||||
else
|
||||
{
|
||||
dataMap[url] = getSuspendJson(url)
|
||||
return dataMap[url]!!
|
||||
}
|
||||
}
|
||||
|
||||
suspend fun getSuspendJson(url: String): com.beust.klaxon.JsonObject =
|
||||
Parser.default().parse(
|
||||
StringBuilder(url.httpGet().awaitString())
|
||||
) as JsonObject
|
||||
) as com.beust.klaxon.JsonObject
|
||||
|
||||
suspend fun getJsonArray(url: String): JsonArray<String> =
|
||||
Klaxon().parseArray<String>(
|
||||
|
|
Loading…
Reference in a new issue