开源库地址: https://github.com/bk192077/struct_mapping.git
支持结构体,std::strng, std::vcetor, std::list, std::map, std::multimap等类型
注意:需要std c++17 及以上版本支持
测试程序:
#include "struct_mapping/struct_mapping.h"
#include
#include
#include
构建指令: g++ ./struct-lys.cpp -std=c++17 -o sl.out -I /home/lys/usr/local/include
运行结果
{
"president": {
"name": "xiaoli-feidao",
"mass": 123.4,
"vec": [
1,
2,
3,
4,
5
],
"lst": [
"abc",
"def"
],
"l": {
"str": "abc",
"mlt": {
"one": 1,
"two": 2,
"zero": 0
}
}
}
}{
"president": {
"name": "JACK-LEE",
"mass": 76.5,
"vec": [
1,
2,
3,
4,
5
],
"lst": [
"abc",
"def",
"Zara"
],
"l": {
"str": "Scientific Persons",
"mlt": {
"aaa": -2,
"bbb": -1,
"one": 1,
"two": 2,
"zero": 0
}
}
}
}