コード例 #1
0
ファイル: WriteTagRequestJSON.cpp プロジェクト: 4ukuta/core
QByteArray WriteTagRequestJSON::getJson() const
{
  QJson::Serializer serializer;
  QVariantMap request;

  Tag mark = m_tags.at(0);

  Channel channel = m_channels.at(0);
  request.insert("auth_token", m_token);
  request.insert("channel", channel.getName());
  request.insert("title", mark.getLabel().isEmpty()? "New mark":mark.getLabel());
  request.insert("link", mark.getUrl());
  request.insert("description", mark.getDescription());
  request.insert("latitude", mark.getLatitude());
  request.insert("altitude", mark.getAltitude());
  request.insert("longitude", mark.getLongitude());
  request.insert("time", mark.getTime().toString("dd MM yyyy HH:mm:ss.zzz"));
  return serializer.serialize(request);
}
コード例 #2
0
ファイル: LoadTagsResponseJSON.cpp プロジェクト: 4ukuta/core
QByteArray LoadTagsResponseJSON::getJson() const
{
    QJson::Serializer serializer;
    serializer.setDoublePrecision(DOUBLE_PRECISION_RESPONSE);
    QVariantMap obj, rss, jchannel;

    QVariantList jchannels;

    QVariantList jtags;
    QVariantMap channel;

    obj["errno"]= m_errno;

    if (m_errno == SUCCESS){
	    for(int j=0; j<m_tags.size(); j++)
	    {
		Tag tag = m_tags.at(j);
		QVariantMap jtag;
		jtag["title"] = tag.getLabel();
		jtag["link"] = tag.getUrl();
		jtag["description"] = tag.getDescription();
		jtag["latitude"] = tag.getLatitude();
		jtag["altitude"] = tag.getAltitude();
		jtag["longitude"] = tag.getLongitude();
		jtag["user"] = tag.getUser().getLogin();
		jtag["pubDate"] = tag.getTime().toString("dd MM yyyy HH:mm:ss.zzz");
		jtags.append(jtag);
	    }
	    channel["items"] = jtags;
	//    channel["name"] = m_channels.at(i).getName();
	    jchannels.append(channel);

	    jchannel["items"] = jchannels;
	    rss["channels"] = jchannel;
	    obj["rss"] = rss;
    }
    return serializer.serialize(obj);
}