![]() |
|
[C] Parsing JSON - Printable Version +- Hack Forums (https://hackforums.net) +-- Forum: Tech (https://hackforums.net/forumdisplay.php?fid=444) +--- Forum: Coding (https://hackforums.net/forumdisplay.php?fid=151) +---- Forum: Software Development (https://hackforums.net/forumdisplay.php?fid=118) +---- Thread: [C] Parsing JSON (/showthread.php?tid=5937474) |
Parsing JSON - int main() - Feb 4, 2019 Code json object = bsoncxx::to_json(*maybe_result);I'm trying to find the value of the index called "username" so i only want the value it holds, which should be admin. But the problem is i cant parse it, it always returns false how it looks: http://prntscr.com/mgfweq response: http://prntscr.com/mgfwj8 using https://github.com/nlohmann/json RE: Parsing JSON - Abruptum - Feb 4, 2019 (Feb 4, 2019 06:22 AM)int main() Wrote: Can you post the full code & json ? we can't help you without them due the fact that we can't know if you even read in the correct area.. RE: Parsing JSON - 0xDEAD10CC - Feb 4, 2019 Code #include <nlohmann/json.hpp>Works just fine for me. If there is an issue, it's with the result of your input json object... Code {"username":"admin"}There is a parse() method too. I haven't even really looked but I'd imagine that's what the literal overload resolves to. RE: Parsing JSON - int main() - Feb 4, 2019 (Feb 4, 2019 06:02 PM)0xDEAD10CC Wrote: Yep had to use the parse, ty! |