-
-
Notifications
You must be signed in to change notification settings - Fork 6.6k
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
小米 MIX4 MIUI13 bug #3316
Comments
The exception message states the issue: you have an unescaped null byte in your input. This is invalid JSON - null bytes must be escaped to This is not a bug in the library. |
using json = nlohmann::ordered_json; int json_code_int = result["code"].get < int >(); This is my code, how to solve the problem you mentioned? I want to get code and msg! thanks |
I assume line json result = json::parse(user_data); throws the exception, right? |
This is my code. There is no problem with Xiaomi 9 input! Xiaomi 4mix miui13 output is like this. |
Look at my new reply above and see what the problem is. Thank you. |
If you enter the |
using json = nlohmann::ordered_json;
char json_msg[4096] = "";
char mem[4096] = "";
int json_code_int;
int json_time_int;
try
{
json result = json::parse(user_data);
sprintf(json_msg, "%s", result["msg"].get < std::string > ().c_str());
json_code_int = result["code"].get < int >();
json_time_int = result["time"].get < int >();
printf("msg:%s\ncode:%d\ntime:%d\n\n", json_msg, json_code_int,json_time_int);
} catch(json::exception & e)
{
sprintf(mem, "%s", e);
printf("mistake:%s\n\n", mem);
} This is the e I printed, and the error output is empty. Look at my circle. Is there something wrong with my printing error code? |
Please use std::cout << "exception: " << e.what() << std::endl; |
The error is the same. There is an unescaped null byte in your input, and the parser rightfully complains that this is invalid JSON. What type does |
const char *user_data = User_login(secret_key, app, appkey, Urlry, kmm, kmm_m, jqm);
printf("\nuser_data:%s\n\n", user_data); This is the code of my user_data. I have no problem with my phone, my friend's phone has a problem, so I don't know what to do |
Please double check that there is a null byte in the input of the parser. Can you print the output of |
This comment was marked as duplicate.
This comment was marked as duplicate.
That's really strange. Can you please try to copy std::string tmp = user_data;
std::cout << "strlen: " << std::strlen(user_data) << " - size(): " << tmp.size() << std::endl;
json result = json::parse(tmp); |
|
The strlen of 0 looks bad, and the error message as well. Can you please run your code with address sanitizer or Valgrind? There seem to be some memory problem. |
My guess at this point is that Is the |
Thank you for your answers. I gave up json and directly intercepted the data. This way the compatibility is better. My friend's mobile phone and I have no problem. Thank you for your answers. Thank you |
Thank you for your answers. I gave up json and directly intercepted the data. This way the compatibility is better. My friend's mobile phone and I have no problem. Thank you for your answers. Thank you |
If you can, you can delete this question, I solved it, thank you author |
The screenshot of the interception in this mobile phone C is garbled as follows. My miui12 interception is normal. Can I reply to it?
![image](https://user-images.githubusercontent.com/55979795/152297289-f3c449ab-6bdd-420f-a942-f77cb738d19b.png)
The text was updated successfully, but these errors were encountered: