Replies: 2 comments
-
even I put everything in global namespace, nothing work :( |
Beta Was this translation helpful? Give feedback.
0 replies
-
// I forgot this!
struct normal_data {
int64_t data;
};
struct normal_data_with_layer : normal_data {
using layer_data = std::array<int64_t, 8>;
using normal_data::normal_data;
layer_data layer;
};
NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(normal_data, data);
NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(normal_data_with_layer, data, layer);
// and parse is not needed
j = nlohmann::json{
{a1_name, nlohmann::json::parse(data.a1)},
{a2_name, nlohmann::json::parse(data.a2)},
{a3_name, nlohmann::json::parse(data.a3)},
{a4_name, nlohmann::json::parse(data.a4)},
{a5_name, nlohmann::json::parse(data.a5)}};
}
// but...
// result of std::cout << std::setw(4) << j.dump(4) << std::endl;
[
{
"a1": [
[
2,
{
"data": 2
}
],
[
1,
{
"data": 2
}
]
],
"a2": [
[
2,
{
"data": 1
}
],
[
1,
{
"data": 1
}
]
],
"a3": [
[
20,
{
"data": 20
}
]
],
"a4": [
[
10,
{
"data": 10
}
]
],
"a5": [
[
100,
{
"data": 20,
"layer": [
1,
2,
3,
0,
0,
0,
0,
0
]
}
]
]
}
]
// too many parentheses... |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
Life4gal
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Beta Was this translation helpful? Give feedback.
All reactions