Hi,
I am a very new to this one. How to install QJson in mac
Thanks in advance
Hi,
I am a very new to this one. How to install QJson in mac
Thanks in advance
What did you already try?
http://qjson.sourceforge.net/get_it/unix.html
Thanks. But it shows the error : "You are building a 64-bit application, but using a 32-bit version of Qt. Check your build configuration." please help me.
Use a 64-bit version of Qt or build the application using a 32-bit compiler.
Girija (14th September 2010)
Hi,
thank you very much.. My json output look like [{"id":2,"name":"AAA"},{"id":1,"name":"BBB"}]. I want to parse this using Qjson in mac. I am trying to parsing but I could not get any outputs . please help me.
Thanks in advance
I am using the following code,
QJson::Parser parser;
bool ok;
QVariantMap result = parser.parse (cityReply->readAll(), &ok).toMap();
if (!ok) {
qFatal("An error occurred during parsing");
exit (1);
}
qDebug() << "Name :" << result.value("name").toString();
}
the output is : Name : ""
Note : if I displays cityReply->readAll() in messagebox then I can view the webservice result (json String).
Your map is empty.
About the toMap() function:
Check with canConvert.Returns the variant as a QMap<QString, QVariant> if the variant has type() Map; otherwise returns an empty map.
Thanks. I am trying this one.
Could you explain little bit more?
I browsed the QJson website a little.
You should be able to convert the variant to a map, but it's always a good idea to check first.
Qt Code:
if (result.canConvert<QMap>()) { QVariantMap resultMap = result.toMap(); } else { qDebug() << "Can not convert to a map."; }To copy to clipboard, switch view to plain text mode
Thanks . But I am getting the error "error: no matching function for call to 'QVariant::canConvert()'.
Is it possible to convert the QByteArray to QMap?
I am using the following code,
QVariant result = parser.parse (cityReply->readAll(), &ok);
if (result.canConvert<QMap>()) {
QVariantMap resultMap = result.toMap();
} else {
qDebug() << "Can not convert to a map.";
}
Please point out any mistakes
What compiler are you using? MSVC6? Unlikely (it seems you are on a Mac), so it should be working. Is this your exact code?
yes .. This is my exact code.
It should be:
Qt Code:
result.canConvert<QVariantMap>()To copy to clipboard, switch view to plain text mode
Hi,
I could not convert the Json result into QVarientMap.
The canConvert function returns false value.
is there any other option?
could you please tell me other options for solve this one?
Thanks in advance.
Bookmarks