-
-
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
error parse #1518
Comments
with gbk, chinese |
json throw JSON_THROW(static_cast<const detail::out_of_range>(&ex)); |
The JSON above is indeed valid and the following program works: #include "json.hpp"
#include <iostream>
using json = nlohmann::json;
int main() {
json j = R"({"Code":1,"Message":"用户登录成功","Data":{"Token":"146A307B82184AB5A00918CF9B612160","User":{"UserId":"3cd1cd06-3d77-4efb-a78d-ad9a9cea3d80","RealName":"admin","Department":"测试1"},"Settings":null},"PageIndex":null,"PageSize":null,"TotalCount":null,"TotalPageCount":null})"_json;
std::cout << j.dump(2) << std::endl;
} The library does only support UTF-8 though. Other encodings are not supported. The error may come from a misinterpretation of GBK. |
thank, but in my point, the gbk and utf8 or other codepage, the ascii part is same, the process of interpretation should not mistake. just like tinyxml2, it work well with gbk or utf8. |
But your value does not only contain ASCII values. For this library, it makes a difference whether |
00-7F 0xxx xxxx //ascii and gbk, utf8 same what i want voice is that, if any char first bit is 1, you shoud process it as text, and do need to interpretate it, what we interest and need to interpretate is the char value below 128(unsinged) |
if a str is abc , so it is 0xxx xxxx, 0xxx xxxx, 0xxx xxxx |
Could you please attach the above JSON as file, so I can check myself? |
ok, wait half hours |
git@github.com:ChinaCCF/TestJSON.git |
the file commit here, and i recheck again, the same error |
Thanks! Here is the error message I get:
And indeed, the string This library does not support any other encoding but UTF-8. The encoding of |
i like your lib very much, it's Intuitive , and simple. but if it do not support gbk, i feel sad, and use rapidjson(china tencent) insead of nlohmann. i think in the world (in win32) , there are many other program run in code page that is not utf8. |
Sorry to hear that. |
{"Code":1,"Message":"用户登录成功","Data":{"Token":"146A307B82184AB5A00918CF9B612160","User":{"UserId":"3cd1cd06-3d77-4efb-a78d-ad9a9cea3d80","RealName":"admin","Department":"测试1"},"Settings":null},"PageIndex":null,"PageSize":null,"TotalCount":null,"TotalPageCount":null}
this json str can't parse through
The text was updated successfully, but these errors were encountered: