0

我有 base64 字符串 eyJod2liOmZhbHNlfV19 我使用 jsoncons lib。我想将此字符串解码为 json oblect。我怎样才能做到这一点?

4

1 回答 1

0
#include <jsoncons/json.hpp>

using namespace jsoncons;

int main()
{
    std::string input = "eyJod2liOmZhbHNlfV19";

    std::string buffer;
    jsoncons::decode_base64(input.begin(), input.end(), buffer);
    std::cout << buffer << "\n\n";

    try
    {
        auto j = json::parse(buffer);
    }
    catch (const std::exception& e)
    {
        std::cout << e.what() << "\n";
    }
}
于 2020-06-25T14:19:05.940 回答