vendredi 4 août 2017

jsoncpp: convert string to double

I am trying to take a string, that I know represents a decimal, from a JSON object and assign it to a double in C++.

One would expect that asDouble() does the job, but this is not the case. For example if we have the array ["0.4983", "4387"] sitting in a variable Json::Value arr, doing

double x = arr[0].asDouble()

throws an exception Value is not convertible to double.

What is the recommended way of doing this (in C++ 11)?

Aucun commentaire:

Enregistrer un commentaire