Пример #1
0
std::string IMAccountListJSONSerializer::serialize() 
{
	int nCount		   = 0;
	int totalContacts  = 0;
	int onlineContacts = 0;

	openArray( "" );

	for ( IMAccountList::const_iterator it = _imAccountList.begin(); it != _imAccountList.end(); ++it) 
	{
		const IMAccount& imAccount = (*it).second;

		if ( !imAccount.isSip() )
		{
			openObject();

			addValue( "id",				imAccount.getKey()			);
			addValue( "login",			imAccount.getLogin()		);
			addValue( "qtprotocol",		imAccount.getQtProtocol()   );
			addValue( "qtprotocolname", QtEnumIMProtocolMap::getQtProtocolName( imAccount.getQtProtocol() ) );

			closeObject();
		}
	}

	closeArray();

	std::string result = toString( false );

	return result;
}
Пример #2
0
/**
 * Start a new field with array as content. Internal values must be declared
 * with printFormattedValue() or printValue().
 * It must be closed by closeFieldArray().
 * @param name Name of the field to declare.
**/
void JsonState::openFieldArray(const char* name)
{
	openField(name);
	openArray();
}