A high-level, general-purpose programming language, created as an extension of the C programming language, that has object-oriented, generic, and functional features in addition to facilities for low-level memory manipulation.
@Noah Aas, Welcome to Microsoft Q&A, you could use the following code to get int and double from jsonobject directly.
JsonObject obj;
hstring jsonstr = winrt::to_hstring(L"{\"MessageId\":\"0815-777\",\"Station\":\"X\",\"Number\":\"123.41\",\"Order\":\"0815-2025-03-20\"}");
int helpInt = 0;
double helpDouble = 0;
if (JsonObject::TryParse(jsonstr, obj))
{
helpDouble = std::stod(obj.GetNamedString(L"Number").c_str());
helpInt = static_cast<int>(helpDouble);
std::wcout << L"Number: " << helpDouble << std::endl;
std::wcout << L"Number: " << helpInt << std::endl;
}
Result:
Best Regards,
Jack
If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.