在Qt的JSON实现中,
QJsonObject
类中有两个运算符的实现(文档在这里):QJsonValue QJsonObject::operator[](const QString & key) const;
QJsonValueRef QJsonObject::operator[](const QString & key);
首先,相比于返回QJsonValue
,返回QJsonValueRef
的优势是什么?其次,如果我只是说类似root['time']
这样的话,将返回哪个值,其中root
是一个QJsonObject
?
const
强制转换会放在root
周围,对吗?像这样((const)root)['time']
。 - saiarcot895