Convert a string to json object properly

Mukit, Ataul - Sep 27 '18 - - Dev Community

Some of us ran into problem when it came to converting a std::string or a const char* string properly to json object by nlohmann (https://github.com/nlohmann/json).
Here is how I achieved it :

#include <string>
#include <iostream>>
#include <sstream>


#include "json.hpp"
using namespace nlohmann;

json toJson(const char* jsonString){
    json jsonObj;
    std::stringstream(jsonString) >> jsonObj;

    return jsonObj;

}

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Terabox Video Player