diff --git a/apps/thtml2json.cpp b/apps/thtml2json.cpp
index a49dbca..48df5c8 100644
--- a/apps/thtml2json.cpp
+++ b/apps/thtml2json.cpp
@@ -11,8 +11,11 @@ Json::JToken Html2JToken(std::shared_ptr node) {
obj.SetValue("Tag", node->text_or_tag);
Json::JObject attrs;
for (auto &item : node->attributes) {
- attrs.SetValue(item.first,
- item.second.value_or(nullptr));
+ if (item.second) {
+ attrs.SetValue(item.first, *item.second);
+ } else {
+ attrs.SetValue(item.first, nullptr);
+ }
}
obj.SetValue("Attributes", attrs);