0
0
Fork 0
mirror of https://github.com/YTVanced/VancedManager synced 2024-11-16 07:45:06 +00:00

Merge pull request #149 from ostajic/dev

lag Fix v1
This commit is contained in:
Tornike Khintibidze 2020-09-14 09:20:29 +04:00 committed by GitHub
commit 5681b6fb4f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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>(