diff --git a/src/solanaceae/message3/nj/message_components.hpp b/src/solanaceae/message3/nj/message_components.hpp index f1d3ff8..451adfe 100644 --- a/src/solanaceae/message3/nj/message_components.hpp +++ b/src/solanaceae/message3/nj/message_components.hpp @@ -14,7 +14,12 @@ namespace Message::Components { NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(ContactFrom, c) NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(ContactTo, c) NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(Read, ts) - // TODO: SyncedBy + + + NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(ReceivedBy, ts) + // ReadBy + // SyncedBy + NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(MessageText, text) // TODO: remove @@ -27,3 +32,27 @@ namespace Message::Components { } // Message::Components +namespace entt { + // is this really not needed? + //template + //inline void to_json(nlohmann::json& j, const dense_map& m) { + //} + + // TODO: using the internal stuff might be bad for abi + template + inline void from_json(const nlohmann::json& j, dense_map& m) { + if (!j.is_array()) { + throw (nlohmann::detail::type_error::create(302, nlohmann::detail::concat("type must be array, but is ", j.type_name()), &j)); + } + + m.clear(); + + for (const auto& p : j) { + if (!p.is_array()) { + throw (nlohmann::detail::type_error::create(302, nlohmann::detail::concat("type must be array, but is ", p.type_name()), &j)); + } + m.emplace(p.at(0).template get(), p.at(1).template get()); + } + } +} // entt + diff --git a/src/solanaceae/message3/nj/message_components_serializer.cpp b/src/solanaceae/message3/nj/message_components_serializer.cpp index 7f56418..8d17269 100644 --- a/src/solanaceae/message3/nj/message_components_serializer.cpp +++ b/src/solanaceae/message3/nj/message_components_serializer.cpp @@ -13,10 +13,15 @@ void registerMessageComponents(MessageSerializerNJ& msnj) { msnj.registerDeserializer(); msnj.registerSerializer(); msnj.registerDeserializer(); + msnj.registerSerializer(); msnj.registerDeserializer(); msnj.registerSerializer(); msnj.registerDeserializer(); + + msnj.registerSerializer(); + msnj.registerDeserializer(); + msnj.registerSerializer(); msnj.registerDeserializer(); msnj.registerSerializer();