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(), 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(),
) )

View File

@@ -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(),
) )
} }

View File

@@ -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(),
) )
} }