Skip to content

Commit 0571ff3

Browse files
committed
Add type & value fields to primitive json types
This aligns with how custom types are exported to JSON.
1 parent ddc958e commit 0571ff3

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

src/json_export.cpp

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,19 +16,23 @@ bool JsonExporter::toJson(const Any& any, nlohmann::json& dst) const
1616

1717
if(any.isString())
1818
{
19-
dst = any.cast<std::string>();
19+
dst["type"] = "string";
20+
dst["value"] = any.cast<std::string>();
2021
}
2122
else if(type == typeid(int64_t))
2223
{
23-
dst = any.cast<int64_t>();
24+
dst["type"] = "int64_t";
25+
dst["value"] = any.cast<int64_t>();
2426
}
2527
else if(type == typeid(uint64_t))
2628
{
27-
dst = any.cast<uint64_t>();
29+
dst["type"] = "uint64_t";
30+
dst["value"] = any.cast<uint64_t>();
2831
}
2932
else if(type == typeid(double))
3033
{
31-
dst = any.cast<double>();
34+
dst["type"] = "double";
35+
dst["value"] = any.cast<double>();
3236
}
3337
else
3438
{

0 commit comments

Comments
 (0)