forked from Cookies_Github_mirror/AquaDX
[+] Wacca user/status/login
This commit is contained in:
@@ -111,6 +111,10 @@ fun Str.asDateTime() = try { LocalDateTime.parse(this, DateTimeFormatter.ISO_LOC
|
||||
catch (e: Exception) { try { LocalDateTime.parse(this, ALT_DATETIME_FORMAT) }
|
||||
catch (e: Exception) { null } }
|
||||
|
||||
val Calendar.year get() = get(Calendar.YEAR)
|
||||
val Calendar.month get() = get(Calendar.MONTH) + 1
|
||||
val Calendar.day get() = get(Calendar.DAY_OF_MONTH)
|
||||
|
||||
// Encodings
|
||||
fun Long.toHex(len: Int = 16): Str = "0x${this.toString(len).padStart(len, '0').uppercase()}"
|
||||
fun Map<String, Any>.toUrl() = entries.joinToString("&") { (k, v) -> "$k=$v" }
|
||||
|
||||
@@ -41,6 +41,17 @@ inline fun <reified T> Str.parseJackson() = if (contains("null")) {
|
||||
else JACKSON.readValue(this, T::class.java)
|
||||
fun <T> T.toJson() = JACKSON.writeValueAsString(this)
|
||||
|
||||
inline fun <reified T> String.json() = try {
|
||||
JACKSON.readValue(this, T::class.java)
|
||||
}
|
||||
catch (e: Exception) {
|
||||
println("Failed to parse JSON: $this")
|
||||
throw e
|
||||
}
|
||||
|
||||
fun String.jsonMap(): Map<String, Any?> = json()
|
||||
fun String.jsonArray(): List<Map<String, Any?>> = json()
|
||||
|
||||
|
||||
// KotlinX Serialization
|
||||
@OptIn(ExperimentalSerializationApi::class)
|
||||
|
||||
Reference in New Issue
Block a user