View Full Version : How to install Qjson in mac
Girija
13th September 2010, 08:09
Hi,
I am a very new to this one. How to install QJson in mac
Thanks in advance
wysota
13th September 2010, 23:34
What did you already try?
http://qjson.sourceforge.net/get_it/unix.html
Girija
14th September 2010, 06:17
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.
wysota
14th September 2010, 10:39
Use a 64-bit version of Qt or build the application using a 32-bit compiler.
Girija
14th September 2010, 11:30
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
wysota
14th September 2010, 11:59
So what did you already try?
Girija
14th September 2010, 15:20
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).
tbscope
14th September 2010, 15:35
Your map is empty.
About the toMap() function:
Returns the variant as a QMap<QString, QVariant> if the variant has type() Map; otherwise returns an empty map.
Check with canConvert.
Girija
15th September 2010, 04:51
Thanks. I am trying this one.
Could you explain little bit more?
tbscope
15th September 2010, 05:32
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.
QVariant result = parser.parse (cityReply->readAll(), &ok);
if (result.canConvert<QMap>()) {
QVariantMap resultMap = result.toMap();
} else {
qDebug() << "Can not convert to a map.";
}
Girija
15th September 2010, 10:31
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?
wysota
15th September 2010, 10:36
How are you calling canConvert?
Girija
15th September 2010, 10:42
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
wysota
15th September 2010, 10:42
What compiler are you using? MSVC6? Unlikely (it seems you are on a Mac), so it should be working. Is this your exact code?
Girija
15th September 2010, 11:22
yes .. This is my exact code.
wysota
15th September 2010, 11:57
It should be:
result.canConvert<QVariantMap>()
Girija
15th September 2010, 14:52
Hi,
I could not convert the Json result into QVarientMap.
The canConvert function returns false value.
is there any other option?
wysota
15th September 2010, 15:06
Maybe the library simply can't parse your string.
Girija
15th September 2010, 15:11
could you please tell me other options for solve this one?
:(
Thanks in advance.
wysota
15th September 2010, 15:25
Parse it yourself.
Girija
15th September 2010, 15:38
Thank you very much. I will try to write own parser.
Is it possible to give the basic idea about the parsing?
Girija
17th September 2010, 09:55
Hi,
I can see the parsing the result using Qjson Library itself. Just I made one chance in the code based on the following link http://stackoverflow.com/questions/3...ng-some-issues.
It is working fine.
Thank u very much.
:)
Powered by vBulletin® Version 4.2.5 Copyright © 2024 vBulletin Solutions Inc. All rights reserved.