Unifying the parser for the tag array

This commit is contained in:
Vitor Pamplona
2025-10-28 13:05:57 -04:00
parent bf664ea0c5
commit 0705ee9581
3 changed files with 5 additions and 14 deletions

View File

@@ -32,10 +32,7 @@ class EventManualDeserializer {
pubKey = jsonObject.get("pubkey").asText().intern(),
createdAt = jsonObject.get("created_at").asLong(),
kind = jsonObject.get("kind").asInt(),
tags =
jsonObject.get("tags").toTypedArray {
it.toTypedArray { s -> if (s.isNull) "" else s.asText().intern() }
},
tags = TagArrayManualDeserializer.fromJson(jsonObject.get("tags")),
content = jsonObject.get("content").asText(),
sig = jsonObject.get("sig").asText(),
)

View File

@@ -22,7 +22,7 @@ package com.vitorpamplona.quartz.nip01Core.signers
import com.fasterxml.jackson.databind.JsonNode
import com.vitorpamplona.quartz.nip01Core.core.Event
import com.vitorpamplona.quartz.nip01Core.jackson.toTypedArray
import com.vitorpamplona.quartz.nip01Core.jackson.TagArrayManualDeserializer
class EventTemplateManualDeserializer {
companion object {
@@ -30,10 +30,7 @@ class EventTemplateManualDeserializer {
EventTemplate(
createdAt = jsonObject.get("created_at").asLong(),
kind = jsonObject.get("kind").asInt(),
tags =
jsonObject.get("tags").toTypedArray {
it.toTypedArray { s -> if (s.isNull) "" else s.asText().intern() }
},
tags = TagArrayManualDeserializer.fromJson(jsonObject.get("tags")),
content = jsonObject.get("content").asText(),
)
}

View File

@@ -24,7 +24,7 @@ import com.fasterxml.jackson.core.JsonParser
import com.fasterxml.jackson.databind.DeserializationContext
import com.fasterxml.jackson.databind.JsonNode
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
class RumorDeserializer : StdDeserializer<Rumor>(Rumor::class.java) {
@@ -38,10 +38,7 @@ class RumorDeserializer : StdDeserializer<Rumor>(Rumor::class.java) {
pubKey = jsonObject.get("pubkey")?.asText()?.intern(),
createdAt = jsonObject.get("created_at")?.asLong(),
kind = jsonObject.get("kind")?.asInt(),
tags =
jsonObject.get("tags").toTypedArray {
it.toTypedArray { s -> if (s.isNull) "" else s.asText().intern() }
},
tags = TagArrayManualDeserializer.fromJson(jsonObject.get("tags")),
content = jsonObject.get("content")?.asText(),
)
}