CString GetJsonString() { // TEST ROUNDTRIP SOAP -> JSON CString namesp("http://test.marlin.org/interface"); CString action("FirstAction"); SOAPMessage msg(namesp,action); msg.SetParameter("First", 101); msg.SetParameter("Second",102); XMLElement* elem = msg.AddElement(NULL,"Third",(XmlDataType)XDT_String,""); if(elem) { msg.AddElement(elem,"Fortune",XDT_Integer,"1000000"); msg.AddElement(elem,"Glory", XDT_String, "Indiana Jones"); msg.AddElement(elem,"Diacrit",XDT_String, "יבםףתכהןצ�טאלעשךגמפ�"); } JSONMessage json(&msg); json.SetWhitespace(true); CString str = json.GetJsonMessage(); return str; }
void MongoClient::ensureIndex(const EnsureIndexInfo &oldInfo,const EnsureIndexInfo &newInfo) const { std::string ns = newInfo._collection.ns().toString(); mongo::BSONObj keys = mongo::Robomongo::fromjson(newInfo._request); mongo::BSONObjBuilder toSave; bool cache=true; int version =-1; toSave.append( "ns" , ns ); toSave.append( "key" , keys ); std::string cacheKey(ns); cacheKey += "--"; if ( newInfo._name != "" ) { toSave.append( "name" , newInfo._name ); cacheKey += newInfo._name; } else { std::string nn = _dbclient->genIndexName(keys); toSave.append( "name" , nn ); cacheKey += nn; } if (version >= 0) toSave.append("v", version); if (oldInfo._unique != newInfo._unique) toSave.appendBool("unique", newInfo._unique); if (oldInfo._backGround != newInfo._backGround) toSave.appendBool("background", newInfo._backGround); if (oldInfo._dropDups != newInfo._dropDups) toSave.appendBool("dropDups", newInfo._dropDups); if (oldInfo._sparse != newInfo._sparse) toSave.appendBool("sparse", newInfo._sparse); if (oldInfo._defaultLanguage != newInfo._defaultLanguage) toSave.append("default_language", newInfo._defaultLanguage); if (oldInfo._languageOverride != newInfo._languageOverride) toSave.append("language_override", newInfo._languageOverride); if (oldInfo._textWeights != newInfo._textWeights) toSave.append("weights", newInfo._textWeights); /* if ( _seenIndexes.count( cacheKey ) ) return 0; if ( cache ) _seenIndexes.insert( cacheKey );*/ if (oldInfo._ttl != newInfo._ttl) toSave.append("expireAfterSeconds", newInfo._ttl); MongoNamespace namesp(newInfo._collection.ns().databaseName(), "system.indexes"); mongo::BSONObj obj = toSave.obj(); if (!oldInfo._name.empty()) _dbclient->dropIndex(ns, oldInfo._name); _dbclient->insert(namesp.toString().c_str(), obj); }