You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Does reapidjson support converting an instance of a struct into json string?
And if yes, can the order of the fields be kept in the order of the declaration in the struct?
For example,
struct S {
int Z;
int A;
};
S s = {1,2};
I tried to read the doc but not able to find the answer.
The expect json string is:
{"Z":1, "A":2}
Any sample code would be much appreciated.
The text was updated successfully, but these errors were encountered:
Thanks a lot @miloyip!
I will spend more time on Cereal for the serialization, can I ask you a question, may be stupid, is there any method like writer.Object(...) so that the embedded struct in S can also be printed?
I checked the doc http://rapidjson.org/md_doc_sax.html#Writer but not able to find one.
No. Writer only helps to generate a JSON from those 7 JSON types, not custom defined types.
So you cannot automatically serialize any struct, instead you need to manually write down how to map a struct to JSON.
Does reapidjson support converting an instance of a struct into json string?
And if yes, can the order of the fields be kept in the order of the declaration in the struct?
For example,
struct S {
int Z;
int A;
};
S s = {1,2};
I tried to read the doc but not able to find the answer.
The expect json string is:
{"Z":1, "A":2}
Any sample code would be much appreciated.
The text was updated successfully, but these errors were encountered: