aboutsummaryrefslogtreecommitdiff
path: root/src/event.cpp
diff options
context:
space:
mode:
authorLibravatar Michael J <37635304+buttercat1791@users.noreply.github.com>2024-03-03 11:56:37 -0600
committerLibravatar GitHub <noreply@github.com>2024-03-03 11:56:37 -0600
commit0d87b4053983ec8edaff5b73491b717866876586 (patch)
tree915e73bdcce6d54558f1aea4bcf2ca2813b1d5a4 /src/event.cpp
parentd02431d723f560f511aafa7e4b224046a4322021 (diff)
Create Nostr Service and Add Write Capabilities (#1)v0.0.1
Diffstat (limited to 'src/event.cpp')
-rw-r--r--src/event.cpp38
1 files changed, 38 insertions, 0 deletions
diff --git a/src/event.cpp b/src/event.cpp
new file mode 100644
index 0000000..75f2ee8
--- /dev/null
+++ b/src/event.cpp
@@ -0,0 +1,38 @@
+#pragma once
+
+#include <string>
+#include <vector>
+#include <nlohmann/json.hpp>
+
+#include "nostr.hpp"
+
+using std::string;
+
+namespace nostr
+{
+ nlohmann::json Event::serialize() const
+ {
+ nlohmann::json j = {
+ {"id", this->id},
+ {"pubkey", this->pubkey},
+ {"created_at", this->created_at},
+ {"kind", this->kind},
+ {"tags", this->tags},
+ {"content", this->content},
+ {"sig", this->sig}
+ };
+ return j.dump();
+ };
+
+ void Event::deserialize(string jsonString)
+ {
+ nlohmann::json j = nlohmann::json::parse(jsonString);
+ this->id = j["id"];
+ this->pubkey = j["pubkey"];
+ this->created_at = j["created_at"];
+ this->kind = j["kind"];
+ this->tags = j["tags"];
+ this->content = j["content"];
+ this->sig = j["sig"];
+ };
+}