Why can't qjsonvalue directly convert data to int but indirectly through toVariant?
Solved
General and Desktop
-
@canid
?
What about https://doc.qt.io/qt-5/qjsonvalue.html#toInt ? -
@canid
?
What about https://doc.qt.io/qt-5/qjsonvalue.html#toInt ? -
@jsulm
This class does have the function toInt, but I found that the conversion with this function is 0, which requires toVariant to convert correctly -
@canid Can you show your JSON? toInt() returns 0 if it can't convert the value to an integer.
-
@jsulm
{"user":{"id":"1","username":"admin1","realname":"canid","type":"1"}}
The data for this "type" cannot be converted to int -
@jsulm
{"user":{"id":"1","username":"admin1","realname":"canid","type":"1"}}
The data for this "type" cannot be converted to int