2011-02-13 15 views
13

Como puedo JSON serializar un QVariant (u otro tipo de datos) en Qt. No deseo utilizar una biblioteca externa de terceros como QJsonCómo serializar a JSON en Qt

+0

relacionada → http://stackoverflow.com/questions/15893040/how-to-create-read-write-json-files-in-qt5 –

Respuesta

-3

No hay herramientas internas en Qt para hacerlo. Deberás usar una lib. o rodar su propia implementación

5

Parsing JSON with QT using standard QT library.

Por cierto: ¿por qué no quieren usar QJson? Encapsula muy bien todas las cosas de QScriptValueIterator, haciendo que su código sea más fácil de leer.

+1

@BojanKogoj Todavía existe aquí: https: //web.archive. org/web/20130111091817/http: //qtwiki.remdex.info/Parsing_JSON_with_QT_using_standard_QT_library – kol

18

Solo por mencionar, a partir de QT5, JSON está soportado oficialmente:

JSON Support in Qt

QVariant id(1), name("John Doe"); 
QJsonObject json; 

json["Name"] = name.toString(); 
json.insert("id", id.toInt()); 
+0

Pero, cómo stract una cadena JSON de ella? –

+0

@DanielSantos http://stackoverflow.com/a/28191005/991484 – dtech

Cuestiones relacionadas