We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
In the Serialize custom type example, write and read function should be a template specialization. So,
write
read
// Let's have a 3D vector struct: struct vec3 { float x, y, z; }; // Let's have a triangle struct with 'vec3' members struct Triangle { vec3 a, b, c; }; JSON5_CLASS(Triangle, a, b, c) namespace json5::detail { // Write vec3 as JSON array of 3 numbers template<> inline json5::value write( writer &w, const vec3 &in ) { w.push_array(); w += write( w, in.x ); w += write( w, in.y ); w += write( w, in.z ); return w.pop(); } // Read vec3 from JSON array template<> inline error read( const json5::value &in, vec3 &out ) { return read( json5::array_view( in ), out.x, out.y, out.z ); } } // namespace json5::detail
This is the right way to do this.
Also, please make a note about the #include order. It seems like json5_input.hpp should be included in prior to json5_reflect.hpp.
#include
json5_input.hpp
json5_reflect.hpp
The text was updated successfully, but these errors were encountered:
No branches or pull requests
In the Serialize custom type example,
write
andread
function should be a template specialization.So,
This is the right way to do this.
Also, please make a note about the
#include
order. It seems likejson5_input.hpp
should be included in prior tojson5_reflect.hpp
.The text was updated successfully, but these errors were encountered: