Moves external signer from org.json to jackson parser
This commit is contained in:
@@ -34,9 +34,9 @@ import com.fasterxml.jackson.databind.deser.std.StdDeserializer
|
|||||||
import com.fasterxml.jackson.databind.module.SimpleModule
|
import com.fasterxml.jackson.databind.module.SimpleModule
|
||||||
import com.fasterxml.jackson.module.kotlin.jacksonObjectMapper
|
import com.fasterxml.jackson.module.kotlin.jacksonObjectMapper
|
||||||
import com.vitorpamplona.quartz.encoders.HexKey
|
import com.vitorpamplona.quartz.encoders.HexKey
|
||||||
|
import com.vitorpamplona.quartz.events.Event
|
||||||
import com.vitorpamplona.quartz.events.EventInterface
|
import com.vitorpamplona.quartz.events.EventInterface
|
||||||
import com.vitorpamplona.quartz.events.LnZapRequestEvent
|
import com.vitorpamplona.quartz.events.LnZapRequestEvent
|
||||||
import org.json.JSONArray
|
|
||||||
|
|
||||||
enum class SignerType {
|
enum class SignerType {
|
||||||
SIGN_EVENT,
|
SIGN_EVENT,
|
||||||
@@ -86,15 +86,13 @@ class Result(
|
|||||||
|
|
||||||
fun fromJson(json: String): Result = mapper.readValue(json, Result::class.java)
|
fun fromJson(json: String): Result = mapper.readValue(json, Result::class.java)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Parses the json with a string of events to an Array of Event objects.
|
||||||
|
*/
|
||||||
fun fromJsonArray(json: String): Array<Result> {
|
fun fromJsonArray(json: String): Array<Result> {
|
||||||
val result: MutableList<Result> = mutableListOf()
|
return Event.mapper.readTree(json).map {
|
||||||
val array = JSONArray(json)
|
fromJson(it.asText())
|
||||||
(0 until array.length()).forEach {
|
}.toTypedArray()
|
||||||
val resultJson = array.getJSONObject(it)
|
|
||||||
val localResult = fromJson(resultJson.toString())
|
|
||||||
result.add(localResult)
|
|
||||||
}
|
|
||||||
return result.toTypedArray()
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user