diff --git a/apps/esmtool/jsonexport.hpp b/apps/esmtool/jsonexport.hpp index b8fd626743..87e99c22f7 100644 --- a/apps/esmtool/jsonexport.hpp +++ b/apps/esmtool/jsonexport.hpp @@ -6,8 +6,8 @@ #include #include -#include "nlohmannjson.hpp" #include "labels.hpp" +#include "nlohmannjson.hpp" #include "util.hpp" namespace nlohmann @@ -35,7 +35,7 @@ namespace nlohmann { // obj = ESM::Header(); } - }; + }; template <> struct adl_serializer @@ -145,7 +145,34 @@ namespace nlohmann template <> struct adl_serializer { - static void to_json(json& j, const ESM::Book& obj) { j = json{ { "name", "ESM::Book" } }; } + static void to_json(json& j, const ESM::Book& obj) + { + j["name"] = obj.mName; + j["model"] = obj.mModel; + j["icon"] = obj.mIcon; + + if (!obj.mScript.empty()) + { + j["script"] = obj.mScript.getRefIdString(); + } + + if (!obj.mEnchant.empty()) + { + j["enchantment"] = obj.mEnchant.getRefIdString(); + } + + j["weight"] = obj.mData.mWeight; + j["value"] = obj.mData.mValue; + j["scroll"] = obj.mData.mIsScroll != 0; + j["enchantmentPoints"] = obj.mData.mEnchant; + j["text"] = obj.mText; + + if (obj.mData.mSkillId != -1) + { + j["skillId"] = obj.mData.mSkillId; + j["skillName"] = skillLabel(obj.mData.mSkillId); + } + } static void from_json(const json& j, ESM::Book& obj) { @@ -266,10 +293,7 @@ namespace nlohmann template <> struct adl_serializer { - static void to_json(json& j, const ESM::Global& obj) - { - j = obj.mValue; - } + static void to_json(json& j, const ESM::Global& obj) { j = obj.mValue; } static void from_json(const json& j, ESM::Global& obj) { @@ -280,10 +304,7 @@ namespace nlohmann template <> struct adl_serializer { - static void to_json(json& j, const ESM::GameSetting& obj) - { - j = obj.mValue; - } + static void to_json(json& j, const ESM::GameSetting& obj) { j = obj.mValue; } static void from_json(const json& j, ESM::GameSetting& obj) { @@ -338,7 +359,10 @@ namespace nlohmann template <> struct adl_serializer { - static void to_json(json& j, const ESM::CreatureLevList& obj) { j = json{ { "name", "ESM::CreatureLevList" } }; } + static void to_json(json& j, const ESM::CreatureLevList& obj) + { + j = json{ { "name", "ESM::CreatureLevList" } }; + } static void from_json(const json& j, ESM::CreatureLevList& obj) { diff --git a/apps/esmtool/util.hpp b/apps/esmtool/util.hpp index 81b5e3bdea..1bfe4a271d 100644 --- a/apps/esmtool/util.hpp +++ b/apps/esmtool/util.hpp @@ -17,7 +17,7 @@ namespace EsmTool void save(ESM::ESMWriter& /*writer*/, bool /*deleted*/) {} }; - + std::string trimQuotes(std::string str); std::string hexString8(uint32_t v); nlohmann::json getRecordFlags(uint32_t flags);