qtqjsonobject

Does QJsonValue differ strings of digits from integers?


When I parse json, is there any way to distinct this situations:

my_value = "123"

and

my_value = 123

?


Solution

  • Yes, you can get the type of JSON values. In order to get it, you need to call QJsonValue::type() function. In your case it will return either QJsonValue::String or QJsonValue::Double respectively.