void LocationType::deserialize(Object::Ptr object){ //std::string str = object->get("Latitude").convert<std::string>(); //printf(str.c_str()); if(object->has(LONGITUDE) && !object->isNull(LONGITUDE)){ double d; Var longitude = object->get(LONGITUDE); Object::Ptr subObject = longitude.extract<Object::Ptr>(); if (subObject->has("$")&& !subObject->isNull("$")) { d = subObject->get("$").convert<double>(); }else{ d = longitude.convert<double>(); } this->longitude = d; } if(object->has(LATITUDE) && !object->isNull(LATITUDE)){ double d; Var LatRaw = object->get(LATITUDE); Var longitude = object->get(LATITUDE); Object::Ptr subObject = longitude.extract<Object::Ptr>(); if (subObject->has("$")&& !subObject->isNull("$")) { d = subObject->get("$").convert<double>(); }else{ d = longitude.convert<double>(); } this->latitude = d; } }
void JSONTest::testNullProperty() { std::string json = "{ \"test\" : null }"; Parser parser; Var result; try { DefaultHandler handler; parser.setHandler(&handler); parser.parse(json); result = handler.result(); } catch(JSONException& jsone) { std::cout << jsone.message() << std::endl; assert(false); } assert(result.type() == typeid(Object::Ptr)); Object::Ptr object = result.extract<Object::Ptr>(); assert(object->isNull("test")); Var test = object->get("test"); assert(test.isEmpty()); }
void MeetingConnImpl::OnGetRoomInfo(Object::Ptr object) { FastMutex::ScopedLock autoLock(m_lock); Var varStatus = object->get("status"); int docIndex = 0; int docTotal = 0; int shareDoc = 0; std::string docName = ""; if(object->isNull("shareDoc")==false) { shareDoc = object->get("shareDoc"); if(shareDoc == 1) { docIndex = object->get("docIndex"); docTotal = object->get("docTotal"); docName = object->get("docName").toString(); } } if(varStatus == 0) { Var resultObj; try { resultObj = object->get("result"); } catch(JSONException& jsone) { std::cout << jsone.message() << std::endl; return; } Object::Ptr subObj = resultObj.extract<Object::Ptr>(); Var varRoomName = subObj->get("roomName"); Var varRoomID = subObj->get("roomID"); Var varAdminPassword= subObj->get("adminPassword"); Var varRoomPassword = subObj->get("roomPassword"); Var varAudioType = subObj->get("audioType"); Var varIsPublic = subObj->get("isPublic"); Var varMixAudio = subObj->get("mixAudio"); Var varDefaultVideoSize = subObj->get("defaultVideoSize"); Var varAudioSamplate = subObj->get("audioSamplerate"); Var varStartTime = subObj->get("startTime"); Var varEndTime = subObj->get("endTime"); Var varOnlineUser = subObj->get("onlineUser"); string strRoomName = varRoomName; uint32_t roomID = varRoomID; string strPassword = varRoomPassword; string strAdminPassword = varAdminPassword; uint32_t defaultVideoSize = varDefaultVideoSize; uint32_t audioType = varAudioType; uint32_t isPublic = varIsPublic; uint32_t mixAudio = varMixAudio; uint32_t audioSamplate = 0; time_t startTime = varStartTime; time_t endTime = varEndTime; ROOM_INFO rs; rs.bMixAudio =mixAudio; rs.sampleRate = audioSamplate; rs.speakMode = audioType; rs.defaultVideoSize = defaultVideoSize; rs.ulRoomID = roomID; rs.ulIsPublic = isPublic; rs.roomMode = 1; rs.sampleRate = varAudioSamplate; rs.startTime = startTime; rs.endTime = endTime; if(varOnlineUser.isEmpty()) { rs.onlineUser = 0; } else { rs.onlineUser = varOnlineUser; } if(subObj->has("roomType")) { Var varRoomType = subObj->get("roomType"); unsigned int ulRoomType = varRoomType; rs.roomMode = ulRoomType; } if(subObj->has("bigVideoUser")) { Var varbigVideoUser = subObj->get("bigVideoUser"); uint64_t ulBigVideoUser = varbigVideoUser; rs.bigVideoUser = ulBigVideoUser; } strcpy(rs.strAdminPwd,strAdminPassword.data()); strcpy(rs.strRoomName,strRoomName.data()); MeetingFrameImpl::GetInstance()->On_MeetingEvent_Enter_Room_Result(0,(char*)&rs); if(shareDoc==1) { if(m_pIMeetingEvent) { m_pIMeetingEvent->On_MeetingEvent_OpenDoc(docName,docIndex,docTotal); } } GetRoomUserList(m_ulRoomID); } else { Var varMsg = object->get("msg"); string errMsg = varMsg; MeetingFrameImpl::GetInstance()->On_MeetingEvent_Enter_Room_Result(1,NULL); } }