本文整理汇总了Java中io.vertx.core.json.JsonObject.toString方法的典型用法代码示例。如果您正苦于以下问题:Java JsonObject.toString方法的具体用法?Java JsonObject.toString怎么用?Java JsonObject.toString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类io.vertx.core.json.JsonObject
的用法示例。
在下文中一共展示了JsonObject.toString方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: toString
import io.vertx.core.json.JsonObject; //导入方法依赖的package包/类
@Override
public String toString(){
JsonObject jsObj = new JsonObject();
jsObj.put("touser", openid);
jsObj.put("template_id", templateId);
jsObj.put("url", url);
JsonObject data = new JsonObject();
if(dataMap != null){
for(String key : dataMap.fieldNames()){
JsonObject item = new JsonObject();
item.put("value", dataMap.getString(key));
item.put("color", color);
data.put(key,item);
}
}
jsObj.put("data", data);
return jsObj.toString();
}
示例2: toString
import io.vertx.core.json.JsonObject; //导入方法依赖的package包/类
@Override
public String toString() {
JsonObject json = new JsonObject();
json.put("out_trade_no", this.outTradeNo);
json.put("total_amount", CommonUtils.getStringFromIntFen(Integer.parseInt(this.totalAmount)));
json.put("subject", this.subject);
json.put("product_code", "QUICK_WAP_PAY");
if (null != this.passbackParams) {
try {
json.put("passback_params", URLEncoder.encode(this.passbackParams, AlipayConstants.CHARSET_UTF8));
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
}
return json.toString();
}
示例3: toString
import io.vertx.core.json.JsonObject; //导入方法依赖的package包/类
@Override
public String toString() {
JsonObject bizContentJson = new JsonObject();
if(CommonUtils.notEmptyString(this.outTradeNo)){
bizContentJson.put("out_trade_no", this.outTradeNo);
}
if(CommonUtils.notEmptyString(this.tradeNo)){
bizContentJson.put("trade_no", this.tradeNo);
}
bizContentJson.put("refund_amount", CommonUtils.getStringFromIntFen(this.refundAmount));
if(CommonUtils.notEmptyString(this.refundReason)){
bizContentJson.put("refund_reason", this.refundReason);
}
if(CommonUtils.notEmptyString(this.storeId)){
bizContentJson.put("store_id", this.storeId);
}
return bizContentJson.toString();
}
示例4: writeToBuffer
import io.vertx.core.json.JsonObject; //导入方法依赖的package包/类
@Override
public void writeToBuffer(Buffer buff) {
super.writeToBuffer(buff);
// Now write the remainder of our stuff to the buffer;
final JsonObject profilesAsJson = new JsonObject();
profiles.forEach((name, profile) -> {
final JsonObject profileAsJson = (JsonObject) DefaultJsonConverter.getInstance().encodeObject(profile);
profilesAsJson.put(name, profileAsJson);
});
final String json = profilesAsJson.toString();
byte[] jsonBytes = json.getBytes(StandardCharsets.UTF_8);
buff.appendInt(jsonBytes.length)
.appendBytes(jsonBytes);
}
示例5: toString
import io.vertx.core.json.JsonObject; //导入方法依赖的package包/类
/**
* 重写toString方法;
* 方法将模板消息的内容一层一层封装成json对象,然后将最后的json对象转换成json字符串;
*
* @return json字符串
* Create by quandong
*/
@Override
public String toString(){
JsonObject jsObj = new JsonObject();
JsonObject template = new JsonObject();
JsonObject context = new JsonObject();
// 构造参数数据的json对象
if(dataMap != null){
// 遍历参数数据,将每个item封装成json对象然后放到context的json对象中
for(String key : dataMap.fieldNames()) {
JsonObject item = new JsonObject(); // 用于存储一个item的json对象
item.put("value", dataMap.getString(key)); // 每个item的值
item.put("color", color); // item的颜色
context.put(key,item); // 将item添加到context的json对象中
}
}
context.put("url", url); // 添加跳转url
context.put("head_color", headColor); // 添加标题颜色
context.put("action_name", "点击查看详情"); // 提示信息
// 将模版ID和内容添加到模板json对象中
template.put("template_id", templateId);
template.put("context", context);
// 添加发送用户和模版ID
jsObj.put("to_user_id", openid);
jsObj.put("template", template);
return jsObj.toString(); // 将json对象转换为字符串并返回
}
示例6: prepareCustomText
import io.vertx.core.json.JsonObject; //导入方法依赖的package包/类
public static String prepareCustomText(String openid,String content){
JsonObject jsObj = new JsonObject();
jsObj.put("touser", openid);
jsObj.put("msgtype", MsgType.Text.name());
JsonObject textObj = new JsonObject();
textObj.put("content", content);
jsObj.put("text", textObj);
return jsObj.toString();
}
示例7: deploy
import io.vertx.core.json.JsonObject; //导入方法依赖的package包/类
/**
* Deploy a component with given JSON configuration
*
* @param deployConfig Json configuration corresponding to a component to be deployed
* @param future Future to provide the status of deployment
* @see <a href="http://vertx.io/docs/apidocs/io/vertx/core/Future.html" target="_blank">Future</a>
*/
public void deploy(JsonObject deployConfig, Future<Boolean> future) {
if (null == this.vertx) {
String errMesg = "Not setup yet! Call 'setup' method first.";
logger.error(errMesg);
future.fail(new Exception(errMesg));
return;
}
try {
Schema jsonSchema = BaseUtil.schemaFromResource("/deploy-opts-schema.json");
String jsonData = deployConfig.toString();
BaseUtil.validateData(jsonSchema, jsonData);
} catch (ValidationException vldEx) {
logger.error("Issue with deployment configuration validation!", vldEx);
vldEx
.getCausingExceptions()
.stream()
.map(ValidationException::getMessage)
.forEach((errMsg) -> {
logger.error(errMsg);
});
future.fail(vldEx);
return;
} catch (IOException ioEx) {
logger.error("Issue while loading schema configuration!", ioEx);
future.fail(ioEx);
return;
}
DeployComponent component = this.setupComponent(deployConfig);
this.deployRecords.deploy(component.getIdentifier(), component.getDeployOpts(), future);
}
示例8: syncBatchMaterial
import io.vertx.core.json.JsonObject; //导入方法依赖的package包/类
/**
* 获取素材
* @param mediaType 素材类型
* @param offset 开始位置
* @param count 获取数量
* @return
*/
public static Material syncBatchMaterial(MediaType mediaType, Integer offset, Integer count, Account mpAccount){
String accessToken = getAccessToken(mpAccount);
String url = WxApi.getBatchMaterialUrl(accessToken);
JsonObject bodyObj = new JsonObject();
bodyObj.put("type", mediaType.toString());
bodyObj.put("offset", offset);
bodyObj.put("count", count);
String body = bodyObj.toString();
try {
JsonObject jsonObj = WxApi.httpsRequest(url, "POST", body);
if (jsonObj.containsKey("errcode")) {//获取素材失败
System.out.println(ErrCode.errMsg(jsonObj.getInteger("errcode")));
return null;
}else{
Material material = new Material();
material.setTotalCount(jsonObj.getInteger("total_count"));
material.setItemCount(jsonObj.getInteger("item_count"));
JsonArray arr = jsonObj.getJsonArray("item");
if(arr != null && arr.size() > 0){
List<MaterialItem> itemList = new ArrayList<MaterialItem>();
for(int i = 0; i < arr.size(); i++){
JsonObject item = arr.getJsonObject(i);
MaterialItem materialItem = new MaterialItem();
materialItem.setMediaId(item.getString("media_id"));
materialItem.setUpdateTime(item.getLong("update_time")*1000L);
if(item.containsKey("content")){//mediaType=news (图文消息)
JsonArray articles = item.getJsonObject("content").getJsonArray("news_item");
List<MaterialArticle> newsItems = new ArrayList<MaterialArticle>();
for(int j = 0; j < articles.size(); j++){
JsonObject article = articles.getJsonObject(j);
MaterialArticle ma = new MaterialArticle();
ma.setTitle(article.getString("title"));
ma.setThumb_media_id(article.getString("thumb_media_id"));
ma.setShow_cover_pic(article.getString("show_cover_pic"));
ma.setAuthor(article.getString("author"));
ma.setContent_source_url(article.getString("content_source_url"));
ma.setContent(article.getString("content"));
ma.setUrl(article.getString("url"));
newsItems.add(ma);
}
materialItem.setNewsItems(newsItems);
}else{
materialItem.setName(item.getString("name"));
materialItem.setUrl(item.getString("url"));
}
itemList.add(materialItem);
}
material.setItems(itemList);
}
return material;
}
} catch (Exception e) {
e.printStackTrace();
}
return null;
}
示例9: from
import io.vertx.core.json.JsonObject; //导入方法依赖的package包/类
public static String from(final JsonObject value) {
return null == value ? Strings.EMPTY : value.toString();
}