00001 /* 00002 Copyright © 2010 julien lopez 00003 00004 This file is part of QExtend. 00005 00006 QExtend is free software: you can redistribute it and/or modify 00007 it under the terms of the GNU General Public License as published by 00008 the Free Software Foundation, either version 3 of the License, or 00009 any later version. 00010 00011 QExtend is distributed in the hope that it will be useful, 00012 but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00014 GNU General Public License for more details. 00015 00016 You should have received a copy of the GNU General Public License 00017 along with QExtend. If not, see <http://www.gnu.org/licenses/>. 00018 */ 00019 00020 #ifndef QEXTEND_JSONPARSER_HPP 00021 #define QEXTEND_JSONPARSER_HPP 00022 00023 00024 #include <Core/qextend_global> 00025 #include <QtCore/QVariant> 00026 00027 namespace QExtend 00028 { 00029 00030 00032 00034 00045 class QEXTEND_EXPORT JsonParser 00046 { 00047 00048 protected: 00049 QString m_lastError; 00052 static QList<QChar> caractereEvitementDebut; 00055 static QList<QChar> caractereEvitementFin; 00060 00061 00062 00064 00073 QVariantMap parseObject( QString object, bool *ok ); 00074 00075 00076 00078 00079 00081 00092 QVariantMap parsePair( const QString& value, bool *ok ); 00093 00094 00095 00097 00098 00100 00110 QVariant parseValue( QString valeur, bool *ok ); 00111 00112 00113 00115 00116 00118 00127 QVariantList parseArray( QString array, bool *ok ); 00128 00129 00130 00132 00133 00135 00142 QVariant parseNumber( const QString& value, bool *ok ); 00143 00144 00145 00147 00148 00150 00157 static QStringList split(QString string, QChar separator); 00158 00159 public: 00160 JsonParser(); 00161 00162 00163 00165 00166 00168 00177 QVariantMap parse(const QString &jsonData, bool *ok = 0); 00178 00179 00180 00182 00183 00185 00192 QString lastError() const; 00193 00194 00195 00197 00198 00200 00207 void clearLastError(); 00208 }; 00209 00210 } 00211 00212 #endif // QEXTEND_JSONPARSER_HPP
© 2000-2025 - www.developpez.com