ibireme / yyjson

The fastest JSON library in C
https://ibireme.github.io/yyjson/doc/doxygen/html/
MIT License
3.12k stars 267 forks source link

Returning NULL in a correct Json #30

Closed luizfernandonb closed 3 years ago

luizfernandonb commented 3 years ago

Describe the bug I have this Json that comes from the Discord API: {\"url\": \"wss://gateway.discord.gg\", \"shards\": 1, \"session_start_limit\": {\"total\": 1000, \"remaining\": 986, \"reset_after\": 1501475, \"max_concurrency\": 1}}\r\n0\r\n\r\n and i do this to try to read it:

yyjson_doc *json_doc = yyjson_read(json, strlen(json), 0);
yyjson_val *root = yyjson_doc_get_root(json_doc);

yyjson_val *url = yyjson_obj_get(root, "url");

But the json_doc pointer always returns NULL, and I don't know what it could be, because I've already checked Json's formatting on a website and it's all right, I've already checked the string and it's all right, I don't know what could be happening anymore

Your environment

Additional context I installed the library by vcpkg

luizfernandonb commented 3 years ago

The problem was this "0" at the end of Json here in: \r\n0\r\n\r\n