Skip to content
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

got an error and cann't figure it out #1351

Closed
addriumruss opened this issue Nov 13, 2018 · 3 comments
Closed

got an error and cann't figure it out #1351

addriumruss opened this issue Nov 13, 2018 · 3 comments
Labels
state: needs more info the author of the issue needs to provide more details

Comments

@addriumruss
Copy link

addriumruss commented Nov 13, 2018

This is my string, which is received from a java server through rabbitmq:

{"cmd":"CONFIG","data":{"para":{"data":{"algorithmSN":0,"algorithmType":0,"cmd":"CONFIG","pid":0,"setAlgorithmSN":false,"setAlgorithmType":false,"setCmd":true,"setParas":false,"setPid":false,"setSn":false,"setTaskId":false},"setData":true,"setState":true,"state":"PUSH"}}}

and got error output:
消息处理异常: [json.exception.type_error.302] type must be string, but is null

but when I extract these string out to a single test cpp file, it parses ok.
this is my test file:

char *str2 = "{\"cmd\":\"CONFIG\",\"data\":{\"para\":{\"data\":{\"algorithmSN\":0,\"algorithmType\":0,\"cmd\":\"CONFIG\",\"pid\":0,\"setAlgorithmSN\":false,\"setAlgorith
mType\":false,\"setCmd\":true,\"setParas\":false,\"setPid\":false,\"setSn\":false,\"setTaskId\":false},\"setData\":true,\"setState\":true,\"state\":\"PUSH\"}}}";
auto doc = json::parse(str2);
string str2_2 = doc.dump();
printf("str2_2=%s \n", str2_2.c_str()); 

is something wrong with my string data?

@nlohmann
Copy link
Owner

The exception does not indicate a parse error, but that you used a function that expected a string, but got a null value. Please run your code in a debugger, and you shall find the line where the exception is thrown. Then we may get an idea on the error.

@nlohmann nlohmann added the state: needs more info the author of the issue needs to provide more details label Nov 13, 2018
@addriumruss
Copy link
Author

@nlohmann Thanks for response! I'll try and see why.

@nlohmann
Copy link
Owner

Can I close the issue?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
state: needs more info the author of the issue needs to provide more details
Projects
None yet
Development

No branches or pull requests

2 participants