本文整理汇总了C++中JObject::put方法的典型用法代码示例。如果您正苦于以下问题:C++ JObject::put方法的具体用法?C++ JObject::put怎么用?C++ JObject::put使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类JObject
的用法示例。
在下文中一共展示了JObject::put方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: build_response
/**
* Build a response text based on result from server method
*/
std::string Proto::build_response(Response& resp) {
JObject* obj = new JObject();
obj->put(Result, resp.get_serializer().getContent());
std::string jsonText = dumps(obj);
delete obj;
return jsonText;
}
示例2: build_error
/**
* Build an error message given error code
*/
std::string Proto::build_error(int code) {
JObject* obj = new JObject();
obj->put(Error, code);
std::string jsonText = dumps(obj);
delete obj;
return jsonText;
}
示例3: build_request
std::string Proto::build_request(
int clientno, int serverno,
int messageid, long timestamp,
size_t method_hash, OutSerializer& sout) {
JObject* obj = new JObject();
obj->put(ClientNo, clientno);
obj->put(ServerNo, serverno);
obj->put(Version, 1);
obj->put(Timestamp, timestamp);
obj->put(MessageId, messageid);
obj->put(Method, method_hash);
obj->put(Param, sout.getContent());
std::string msg = dumps(obj);
delete obj;
return msg;
}