-
-
Notifications
You must be signed in to change notification settings - Fork 6.8k
New issue
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
Does json support converting an instance of a struct into json string? #1143
Comments
Do you really mean reapidjson? |
Thank you for the quick response and sorry for the typo. |
From the README:
|
What I mean is that the library does support serializing user-defined types to JSON (https://github.com/nlohmann/json#arbitrary-types-conversions), but does not preserve the order of object keys by default. This can be achieved by the containers linked in the README snippet above. |
I did get similar information via searching, and I also remember that you mentioned in one of your reply that you will not recommend fifo_map. |
Using the fifo_map header is not really tested and there may be issues with that. But the more people try it, the better we know ;-) |
If you experience any issues, please let me know! |
Does json 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.
Some background information for this question:
I am developing a Qt client for a blockchain. I need to sign for a transaction struct json. But the json fields are in the order of alphabet, however on the server side, golang json packeg, the order is the declaration order of the struct fields. Hence the verification for the signature failed.
The text was updated successfully, but these errors were encountered: