mirror of
https://github.com/vitorpamplona/amethyst.git
synced 2025-11-10 23:36:42 +01:00
Unifying the parser for the tag array
This commit is contained in:
@@ -32,10 +32,7 @@ class EventManualDeserializer {
|
|||||||
pubKey = jsonObject.get("pubkey").asText().intern(),
|
pubKey = jsonObject.get("pubkey").asText().intern(),
|
||||||
createdAt = jsonObject.get("created_at").asLong(),
|
createdAt = jsonObject.get("created_at").asLong(),
|
||||||
kind = jsonObject.get("kind").asInt(),
|
kind = jsonObject.get("kind").asInt(),
|
||||||
tags =
|
tags = TagArrayManualDeserializer.fromJson(jsonObject.get("tags")),
|
||||||
jsonObject.get("tags").toTypedArray {
|
|
||||||
it.toTypedArray { s -> if (s.isNull) "" else s.asText().intern() }
|
|
||||||
},
|
|
||||||
content = jsonObject.get("content").asText(),
|
content = jsonObject.get("content").asText(),
|
||||||
sig = jsonObject.get("sig").asText(),
|
sig = jsonObject.get("sig").asText(),
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ package com.vitorpamplona.quartz.nip01Core.signers
|
|||||||
|
|
||||||
import com.fasterxml.jackson.databind.JsonNode
|
import com.fasterxml.jackson.databind.JsonNode
|
||||||
import com.vitorpamplona.quartz.nip01Core.core.Event
|
import com.vitorpamplona.quartz.nip01Core.core.Event
|
||||||
import com.vitorpamplona.quartz.nip01Core.jackson.toTypedArray
|
import com.vitorpamplona.quartz.nip01Core.jackson.TagArrayManualDeserializer
|
||||||
|
|
||||||
class EventTemplateManualDeserializer {
|
class EventTemplateManualDeserializer {
|
||||||
companion object {
|
companion object {
|
||||||
@@ -30,10 +30,7 @@ class EventTemplateManualDeserializer {
|
|||||||
EventTemplate(
|
EventTemplate(
|
||||||
createdAt = jsonObject.get("created_at").asLong(),
|
createdAt = jsonObject.get("created_at").asLong(),
|
||||||
kind = jsonObject.get("kind").asInt(),
|
kind = jsonObject.get("kind").asInt(),
|
||||||
tags =
|
tags = TagArrayManualDeserializer.fromJson(jsonObject.get("tags")),
|
||||||
jsonObject.get("tags").toTypedArray {
|
|
||||||
it.toTypedArray { s -> if (s.isNull) "" else s.asText().intern() }
|
|
||||||
},
|
|
||||||
content = jsonObject.get("content").asText(),
|
content = jsonObject.get("content").asText(),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ import com.fasterxml.jackson.core.JsonParser
|
|||||||
import com.fasterxml.jackson.databind.DeserializationContext
|
import com.fasterxml.jackson.databind.DeserializationContext
|
||||||
import com.fasterxml.jackson.databind.JsonNode
|
import com.fasterxml.jackson.databind.JsonNode
|
||||||
import com.fasterxml.jackson.databind.deser.std.StdDeserializer
|
import com.fasterxml.jackson.databind.deser.std.StdDeserializer
|
||||||
import com.vitorpamplona.quartz.nip01Core.jackson.toTypedArray
|
import com.vitorpamplona.quartz.nip01Core.jackson.TagArrayManualDeserializer
|
||||||
import com.vitorpamplona.quartz.nip59Giftwrap.rumors.Rumor
|
import com.vitorpamplona.quartz.nip59Giftwrap.rumors.Rumor
|
||||||
|
|
||||||
class RumorDeserializer : StdDeserializer<Rumor>(Rumor::class.java) {
|
class RumorDeserializer : StdDeserializer<Rumor>(Rumor::class.java) {
|
||||||
@@ -38,10 +38,7 @@ class RumorDeserializer : StdDeserializer<Rumor>(Rumor::class.java) {
|
|||||||
pubKey = jsonObject.get("pubkey")?.asText()?.intern(),
|
pubKey = jsonObject.get("pubkey")?.asText()?.intern(),
|
||||||
createdAt = jsonObject.get("created_at")?.asLong(),
|
createdAt = jsonObject.get("created_at")?.asLong(),
|
||||||
kind = jsonObject.get("kind")?.asInt(),
|
kind = jsonObject.get("kind")?.asInt(),
|
||||||
tags =
|
tags = TagArrayManualDeserializer.fromJson(jsonObject.get("tags")),
|
||||||
jsonObject.get("tags").toTypedArray {
|
|
||||||
it.toTypedArray { s -> if (s.isNull) "" else s.asText().intern() }
|
|
||||||
},
|
|
||||||
content = jsonObject.get("content")?.asText(),
|
content = jsonObject.get("content")?.asText(),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user