I'm trying to dump object from type nlohmann::json
into readable string value from visual studio debugger. So in order to invoke the dump method from the nlohmann::json
instance, i use visual studio intermediate window.
However, it seems like this method doesn't run well and return too few arguments in function call
error although i called it exactly as I should. Also, if I try to set its output to a new std::string type, the debugger cannot identify it.
myJsonObj
{m_type=object (1 '\x1') m_value={object=0x000001303ea66590 { size=2 } array=0x000001303ea66590 { size=1152921422937066337 } ...} }
m_type: object (1 '\x1')
m_value: {object=0x000001303ea66590 { size=2 } array=0x000001303ea66590 { size=1152921422937066337 } string=0x000001303ea66590 "0A_>0\x1" ...}
myJsonObj.dump()
too few arguments in function call
std::string x = myJsonObj.dump()
identifier "x" is undefined
Any idea how to do it properly ?
In the intermediate window, we cannot use the default parameter for the C++ function. You can invoke the dump method like this:
myJsonObj.dump(4, ' ', true, nlohmann::detail::error_handler_t::strict)
However, in the intermediate window, we cannot see a pretty formatted print. You can use the Visual Studio Watch Window to the display returned string. Please see the link here to know about how to use the Watch window: How to make Visual Studio's Immediate window give me plain string output?