-
-
Notifications
You must be signed in to change notification settings - Fork 6.7k
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
merge result not as espected #1279
Comments
I simplified your program and the JSON value (used an empty array so that the changes easier to spot): #include "json.hpp"
#include <iostream>
using nlohmann::json;
int main()
{
const char* j_data = R"(
{
"UniqueId": "",
"_200": []
}
)";
auto j = nlohmann::json::parse(j_data);
std::cout << j << std::endl;
// patch: set/change "UniqueId" to "9999"
nlohmann::json patch = R"({"UniqueId":"9999"})"_json;
j.merge_patch(patch);
std::cout << j << std::endl;
// patch: set/change "Id" to "9999"
nlohmann::json patch2 = R"({"Id":"9999"})"_json;
j.merge_patch(patch2);
std::cout << j << std::endl;
} The patch {"UniqueId":"9999","_200":[]} The patch {"Id":"9999","UniqueId":"9999","_200":[]} I cannot reproduce your findings "Sometimes the whole table is missing in the result and sometimes the field UniqueId appears twice.". What result are you getting and what do you expect? |
The point is that you should not simplify the things. The problem appears only if you work with large tables/arrays. |
I did. Several times. What is the exact problem you encounter? |
As I said above I merged with the UniqueId and this field appears twice in the result Json stream. |
Thanks! |
Note the library uses |
I think I found the problem. I use internally wchar_t and before I call your lib I translate them to ansi char. In the routine WideCharToMultiByte I made a mistake with the length of the unicode string. Now it works. |
Good catch! Thanks for reporting back! |
Hi,
If I try to do the following with the attached table in the header zip I didnt get the expected result.
Do This:
The result is different. Sometimes the whole table is missing in the result and sometimes the field UniqueId appears twice.
Header.zip
The text was updated successfully, but these errors were encountered: