3

How to install the Qjson in mac?

tshepang
  • 12,111
  • 21
  • 91
  • 136
Finder
  • 8,259
  • 8
  • 39
  • 54
  • Just an advice: If you have the answer for your question, it would be great you accept the answer (same for all your open questions with a useful answer). If not, people may not want to help you in the future. – Patrice Bernassola Sep 15 '10 at 12:27
  • Thanks Patrice. I will do it here after. – Finder Sep 15 '10 at 14:30

1 Answers1

1

Refer to the "get it" tab on the QJson website. MacOs X is a Unix system

Edit for parsing:

Try this for your Json string "[{"id":2,"name":"AAA"},{"id":1,"name":"BBB"}]"

QJson::Parser parser;
bool ok;
QVariantMap result=parser.parse (cityReply->readAll(),&ok).toMap();
if (!ok)
{
    qFatal("An error occurred during parsing");
    exit (1);
}

foreach (QVariant city, result.toList())
{
    QVariantMap names = city.toMap();
    qDebug() << "\t-" << names["name"].toString();
}

Please open a new Question if you have an other question.

Patrice Bernassola
  • 14,136
  • 6
  • 46
  • 59
  • 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. – Finder Sep 14 '10 at 05:16
  • 1
    Regarding the error, you need to specify you are building a 32-bit application. Check the build configuration and force 32-bit if necessary – Patrice Bernassola Sep 14 '10 at 06:23
  • Thank u very much Patrice. But, 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. – Finder Sep 14 '10 at 10:45
  • 1
    Have you some errors? Regarding your Json chain it's an array with 2 objects in it. Format seems to be ok – Patrice Bernassola Sep 14 '10 at 12:25
  • 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). – Finder Sep 15 '10 at 09:27
  • 1
    You are getting an array in result. You need to convert it to list to use it and then get the name in each object. See the edit in my answer – Patrice Bernassola Sep 15 '10 at 10:23
  • Hi Patrice, Still I am getting errors like "could not convert QVariantMap to QList". :( I posted as a new question. Please help me. Thanks in advance. – Finder Sep 15 '10 at 14:14