aigmix / aigcjson Goto Github PK
View Code? Open in Web Editor NEWOnly need two lines of code to convert between class and json. 两行代码实现C++ Json与类对象相互转换。
License: MIT License
Only need two lines of code to convert between class and json. 两行代码实现C++ Json与类对象相互转换。
License: MIT License
使用测试README中的测试程序时通过,但转换我自定义的数据结构编译不通过,提示有错误,当我再次使用README中的测试程序时错误却仍然存在。
错误提示为:“static_cast”:无法从“int”转换为“T”--AIGCJson.hpp line 231
错误提示为:“static_cast”:无法从“T”转换为“int”--AIGCJson.hpp line 255
I am trying to use your project for my task.
However , the compiler told me some errors.
I am not sure if the environment led to this problem.
here are the reports.
../src/internet/model/include/rapidjson/internal/meta.h:107: error: expected nested-name-specifier before numeric constant
../src/internet/model/include/rapidjson/internal/meta.h:107: error: expected ‘>’ before numeric constant
../src/internet/model/include/rapidjson/internal/meta.h:109: error: ‘D’ was not declared in this scope
../src/internet/model/include/rapidjson/internal/meta.h:109: error: template argument 1 is invalid
../src/internet/model/include/rapidjson/internal/meta.h:115: error: ISO C++ forbids declaration of ‘D’ with no type
../src/internet/model/include/rapidjson/internal/meta.h:115: error: expected ‘,’ or ‘...’ before ‘*’ token
../src/internet/model/include/rapidjson/internal/meta.h:116: error: ISO C++ forbids declaration of ‘parameter’ with no type
../src/internet/model/include/rapidjson/internal/meta.h:116: error: expected ‘,’ or ‘...’ before numeric constant
../src/internet/model/include/rapidjson/internal/meta.h:119: error: ISO C++ forbids declaration of ‘type name’ with no type
../src/internet/model/include/rapidjson/internal/meta.h:119: error: ISO C++ forbids declaration of ‘type name’ with no type
../src/internet/model/include/rapidjson/internal/meta.h:119: error: declaration of ‘operator const int’ as non-function
../src/internet/model/include/rapidjson/internal/meta.h:119: error: expected ‘;’ before numeric constant
../src/internet/model/include/rapidjson/internal/meta.h:120: error: ISO C++ forbids declaration of ‘type name’ with no type
../src/internet/model/include/rapidjson/internal/meta.h:120: error: ‘operator const int’ does not name a type
../src/internet/model/include/rapidjson/internal/meta.h:126: error: expected nested-name-specifier before numeric constant
../src/internet/model/include/rapidjson/internal/meta.h:126: error: expected ‘>’ before numeric constant
../src/internet/model/include/rapidjson/internal/meta.h:127: error: ‘D’ was not declared in this scope
../src/internet/model/include/rapidjson/internal/meta.h:127: error: type/value mismatch at argument 1 in template parameter list for ‘template<class T, class U> struct rapidjson::internal::IsSame’
../src/internet/model/include/rapidjson/internal/meta.h:127: error: expected a type, got ‘2’
../src/internet/model/include/rapidjson/internal/meta.h:127: error: template argument 2 is invalid
../src/internet/model/include/rapidjson/internal/meta.h:127: error: ‘D’ was not declared in this scope
../src/internet/model/include/rapidjson/internal/meta.h:127: error: wrong number of template arguments (2, should be 1)
../src/internet/model/include/rapidjson/internal/meta.h:107: error: provided for ‘template<int > struct rapidjson::internal::IsBaseOfImpl’
../src/internet/model/include/rapidjson/internal/meta.h:127: error: template argument 1 is invalid
../src/internet/model/include/rapidjson/internal/meta.h:127: error: template argument 1 is invalid
../src/internet/model/include/rapidjson/internal/meta.h:127: error: template argument 2 is invalid
../src/internet/model/include/rapidjson/internal/meta.h:127: error: expected ‘{’ before ‘Type’
../src/internet/model/include/rapidjson/internal/meta.h:127: error: invalid type in declaration before ‘{’ token
../src/internet/model/include/rapidjson/internal/meta.h:127: error: template declaration of ‘int rapidjson::internal::Type’
In file included from ../src/internet/model/include/AIGCJson.hpp:27,
from ../src/internet/model/mp-tcp-socket-base.cc:30:
../src/internet/model/include/rapidjson/document.h:495: error: wrong number of template arguments (2, should be 1)
../src/internet/model/include/rapidjson/internal/meta.h:126: error: provided for ‘template<int > struct rapidjson::internal::IsBaseOf’
../src/internet/model/include/rapidjson/document.h:495: error: expected ‘{’ before ‘Type’
../src/internet/model/include/rapidjson/document.h:495: error: invalid type in declaration before ‘{’ token
../src/internet/model/include/rapidjson/document.h:495: error: template declaration of ‘int rapidjson::internal::Type’
../src/internet/model/include/rapidjson/document.h: In instantiation of ‘rapidjson::internal::IsGenericValue<rapidjson::GenericValue<rapidjson::UTF8, rapidjson::MemoryPoolAllocatorrapidjson::CrtAllocator > >’:
../src/internet/model/include/rapidjson/internal/meta.h:69: instantiated from ‘rapidjson::internal::OrExpr<rapidjson::internal::IsPointer<rapidjson::GenericValue<rapidjson::UTF8, rapidjson::MemoryPoolAllocatorrapidjson::CrtAllocator > >, rapidjson::internal::IsGenericValue<rapidjson::GenericValue<rapidjson::UTF8, rapidjson::MemoryPoolAllocatorrapidjson::CrtAllocator > > >’
../src/internet/model/include/rapidjson/internal/meta.h:145: instantiated from ‘rapidjson::internal::DisableIf<rapidjson::internal::OrExpr<rapidjson::internal::IsPointer<rapidjson::GenericValue<rapidjson::UTF8, rapidjson::MemoryPoolAllocatorrapidjson::CrtAllocator > >, rapidjson::internal::IsGenericValue<rapidjson::GenericValue<rapidjson::UTF8, rapidjson::MemoryPoolAllocatorrapidjson::CrtAllocator > > >, rapidjson::GenericValue<rapidjson::UTF8, rapidjson::MemoryPoolAllocatorrapidjson::CrtAllocator >&>’
../src/internet/model/include/AIGCJson.hpp:431: instantiated from here
../src/internet/model/include/rapidjson/document.h:498: error: invalid use of incomplete type ‘struct rapidjson::internal::IsGenericValueImpl<rapidjson::GenericValue<rapidjson::UTF8, rapidjson::MemoryPoolAllocatorrapidjson::CrtAllocator >, void, void>’
../src/internet/model/include/rapidjson/document.h:491: error: declaration of ‘struct rapidjson::internal::IsGenericValueImpl<rapidjson::GenericValue<rapidjson::UTF8, rapidjson::MemoryPoolAllocatorrapidjson::CrtAllocator >, void, void>’
In file included from ../src/internet/model/include/rapidjson/reader.h:24,
from ../src/internet/model/include/rapidjson/document.h:20,
from ../src/internet/model/include/AIGCJson.hpp:27,
from ../src/internet/model/mp-tcp-socket-base.cc:30:
../src/internet/model/include/rapidjson/internal/meta.h: In instantiation of ‘rapidjson::internal::OrExpr<rapidjson::internal::IsPointer<rapidjson::GenericValue<rapidjson::UTF8, rapidjson::MemoryPoolAllocatorrapidjson::CrtAllocator > >, rapidjson::internal::IsGenericValue<rapidjson::GenericValue<rapidjson::UTF8, rapidjson::MemoryPoolAllocatorrapidjson::CrtAllocator > > >’:
../src/internet/model/include/rapidjson/internal/meta.h:145: instantiated from ‘rapidjson::internal::DisableIf<rapidjson::internal::OrExpr<rapidjson::internal::IsPointer<rapidjson::GenericValue<rapidjson::UTF8, rapidjson::MemoryPoolAllocatorrapidjson::CrtAllocator > >, rapidjson::internal::IsGenericValue<rapidjson::GenericValue<rapidjson::UTF8, rapidjson::MemoryPoolAllocatorrapidjson::CrtAllocator > > >, rapidjson::GenericValue<rapidjson::UTF8, rapidjson::MemoryPoolAllocatorrapidjson::CrtAllocator >&>’
../src/internet/model/include/AIGCJson.hpp:431: instantiated from here
../src/internet/model/include/rapidjson/internal/meta.h:69: error: ‘Value’ is not a member of ‘rapidjson::internal::IsGenericValue<rapidjson::GenericValue<rapidjson::UTF8, rapidjson::MemoryPoolAllocatorrapidjson::CrtAllocator > >’
../src/internet/model/include/rapidjson/internal/meta.h: In instantiation of ‘rapidjson::internal::DisableIf<rapidjson::internal::OrExpr<rapidjson::internal::IsPointer<rapidjson::GenericValue<rapidjson::UTF8, rapidjson::MemoryPoolAllocatorrapidjson::CrtAllocator > >, rapidjson::internal::IsGenericValue<rapidjson::GenericValue<rapidjson::UTF8, rapidjson::MemoryPoolAllocatorrapidjson::CrtAllocator > > >, rapidjson::GenericValue<rapidjson::UTF8, rapidjson::MemoryPoolAllocatorrapidjson::CrtAllocator >&>’:
../src/internet/model/include/AIGCJson.hpp:431: instantiated from here
../src/internet/model/include/rapidjson/internal/meta.h:145: error: ‘Value’ is not a member of ‘rapidjson::internal::OrExpr<rapidjson::internal::IsPointer<rapidjson::GenericValue<rapidjson::UTF8, rapidjson::MemoryPoolAllocatorrapidjson::CrtAllocator > >, rapidjson::internal::IsGenericValue<rapidjson::GenericValue<rapidjson::UTF8, rapidjson::MemoryPoolAllocatorrapidjson::CrtAllocator > > >’
In file included from ../src/internet/model/mp-tcp-socket-base.cc:30:
../src/internet/model/include/AIGCJson.hpp:768: error: expected primary-expression before ‘{’ token
../src/internet/model/include/AIGCJson.hpp:818: error: expected primary-expression before ‘{’ token
Waf: Leaving directory `/home/wjt/eclipse/work-space/finalbs/build'
Build failed
-> task in 'ns3-internet' failed (exit status 1):
{task 140218702466000: cxx mp-tcp-socket-base.cc -> mp-tcp-socket-base.cc.1.o}
['/usr/bin/g++', '-O0', '-ggdb', '-g3', '-Wall', '-Werror', '-std=c++0x', '-Wno-error=deprecated-declarations', '-std=c++0x', '-fstrict-aliasing', '-std=c++0x', '-Wstrict-aliasing', '-fPIC', '-pthread', '-I.', '-I..', '-DNS3_ASSERT_ENABLE', '-DNS3_LOG_ENABLE', '-DHAVE_SYS_IOCTL_H=1', '-DHAVE_IF_NETS_H=1', '-DHAVE_NET_ETHERNET_H=1', '-DHAVE_PACKET_H=1', '-DHAVE_IF_TUN_H=1', '../src/internet/model/mp-tcp-socket-base.cc', '-c', '-o', 'src/internet/model/mp-tcp-socket-base.cc.1.o']
"/home/wjt/eclipse/work-space/finalbs/waf build" terminated with exit code 1. Build might be incomplete.
It's extremely possible that my environment is different with you.
My Environment is gcc/g++ 4.4.7, and the command has added the attribute "-std=c++0x"
Could you please help me? Thanks a lot.
应用场景是使用waf编译工具做ns3项目的二次开发
AIGCJsonToObject中的handle形参和宏参数冲突出现异常。
大佬您好,类中包含double类型属性,如23.3在转换至jsonStr后变为23.299999237060547
我使用vs2015和vs2017编译运行调试,发现test.cpp中的my未能正确赋值,切换为vs2019或者mingw都可以正常显示,想了解下怎么更改可以支持这些版本,因为有些项目还在使用vs2015.
比如这样:
class Student {
public:
string Name[2];
int Age[2];
AIGC_JSON_HELPER(Name, Age)
};
unordered_map不支持
我想用多层的类进行JSON反序列化。
如下
class Popole:PoBase
{
public:
string name;
int age;
AIGC_JSON_HELPER(name, age)//成员注册
};
class Student:Popole{
public:
string depart;
int grade;
AIGC_JSON_HELPER(depart, grade)//成员注册
};
class Class:PoBase{
public:
string name;
list<Student> students;
Popole master;
AIGC_JSON_HELPER(name, students,master)//成员注册
};
{"name":"小一班","master":{"name":"刘老师","age":35},"student":[{"name":"张小明","age":5,"grade":3,"depart":"小学"},{"name":"张小红","age":7,"grade":3,"depart":"小学"}]}
这样的JSON解析不了students
有没有办法解决这类需求呢?
比如
class Student{
....
}
class xxx{
public:
string name;
list students;
}
这种情况如何处理呢?
我测试报
AIGCJson.hpp:257:38: error: no match for 'operator[]' (operand types are 'std::__cxx11::list' and 'int')
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.