本文整理汇总了Java中io.vertx.core.json.JsonArray.add方法的典型用法代码示例。如果您正苦于以下问题:Java JsonArray.add方法的具体用法?Java JsonArray.add怎么用?Java JsonArray.add使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类io.vertx.core.json.JsonArray
的用法示例。
在下文中一共展示了JsonArray.add方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setBase
import io.vertx.core.json.JsonArray; //导入方法依赖的package包/类
private void setBase(String series, Object x, Object y){
for(Object object:((javafx.scene.chart.XYChart)body).getData()){
javafx.scene.chart.XYChart.Series s = (javafx.scene.chart.XYChart.Series)object;
if(s.getName().equals(series)){
for(Object o:s.getData()){
javafx.scene.chart.XYChart.Data datum =(javafx.scene.chart.XYChart.Data)o;
if(x.equals(datum.getXValue())){
datum.setYValue(y);
return;
}
}
addData(s,x,y);
return;
}
}
JsonArray jsonArray = new JsonArray();
JsonObject jsonObject = new JsonObject();
jsonObject.put("x",x).put("y",y);
jsonArray.add(jsonObject);
setSeries(series,jsonArray);
}
示例2: createSetCharHandler
import io.vertx.core.json.JsonArray; //导入方法依赖的package包/类
private Handler<AsyncResult<Set<Character>>> createSetCharHandler(Message msg) {
return res -> {
if (res.failed()) {
if (res.cause() instanceof ServiceException) {
msg.reply(res.cause());
} else {
msg.reply(new ServiceException(-1, res.cause().getMessage()));
}
} else {
JsonArray arr = new JsonArray();
for (Character chr: res.result()) {
arr.add((int) chr);
}
msg.reply(arr);
}
};
}
示例3: createListCharHandler
import io.vertx.core.json.JsonArray; //导入方法依赖的package包/类
private Handler<AsyncResult<List<Character>>> createListCharHandler(Message msg) {
return res -> {
if (res.failed()) {
if (res.cause() instanceof ServiceException) {
msg.reply(res.cause());
} else {
msg.reply(new ServiceException(-1, res.cause().getMessage()));
}
} else {
JsonArray arr = new JsonArray();
for (Character chr: res.result()) {
arr.add((int) chr);
}
msg.reply(arr);
}
};
}
示例4: getSubscriptionBody
import io.vertx.core.json.JsonArray; //导入方法依赖的package包/类
private JsonArray getSubscriptionBody() {
final JsonArray result = new JsonArray();
final JsonObject subscribe = new JsonObject();
final JsonObject ext = new JsonObject();
final JsonObject replay = new JsonObject();
// TODO: Handling of Replay options need to be fixed here!
replay.put(this.getListenerConfig().getListenSubject(), -2);
ext.put("replay", replay);
subscribe.put("ext", ext);
subscribe.put("clientId", this.clientId);
subscribe.put("channel", "/meta/subscribe");
subscribe.put("subscription", this.getListenerConfig().getListenSubject());
subscribe.put("id", "3");
result.add(subscribe);
return result;
}
示例5: makeDefaultConfig
import io.vertx.core.json.JsonArray; //导入方法依赖的package包/类
private JsonObject makeDefaultConfig() {
JsonObject defaultConfig=new JsonObject();
defaultConfig.put(CSRF_PROTECTED, false);
List<String> originsList=new ArrayList<>();
originsList.add(ALLOW_ALL);
defaultConfig.put(ALLOWED_ORIGINS, new JsonArray(originsList));
JsonArray outbound=new JsonArray();
outbound.add(new JsonObject().put(ADDRESS, VertxBusContext.DEFAULT_SOCKJS_ADDRESS));
JsonArray inbound=new JsonArray();
inbound.add(new JsonObject().put(ADDRESS, VertxBusContext.DEFAULT_SOCKJS_ADDRESS));
defaultConfig.put(ADDRESSES, new JsonObject().put(INBOUND, inbound).put(OUTBOUND, outbound));
return defaultConfig;
}
示例6: zip
import io.vertx.core.json.JsonArray; //导入方法依赖的package包/类
static JsonArray zip(
final JsonArray target,
final JsonArray sources,
final String fromKey,
final String toKey
) {
final ConcurrentMap<Integer, Object> targetMap = mapIndex(target, fromKey);
final ConcurrentMap<Object, JsonObject> sourceMap = mapZip(sources, toKey);
final ConcurrentMap<Integer, JsonObject> merged = Statute.reduce(targetMap, sourceMap);
final JsonArray results = new JsonArray();
for (int idx = 0; idx < target.size(); idx++) {
final JsonObject item = append(target.getJsonObject(idx), merged.get(idx), true);
results.add(item);
}
target.clear();
return target.addAll(results);
}
示例7: updateWxPay
import io.vertx.core.json.JsonArray; //导入方法依赖的package包/类
/**
* 更新微信支付配置
*/
public void updateWxPay(JsonObject acc, Handler<Integer> callback) {
Integer id = acc.getInteger(ID);
if(id == null){
throw new IllegalArgumentException("Account ID cannot be null!!!");
}
StringBuilder sql = new StringBuilder("update awp_account set ");
JsonArray params = new JsonArray();
boolean moreThanOne = false;
String mchid = acc.getString(MCHID);
if (mchid != null && !mchid.equals("")) {
sql.append("mchId=?");
params.add(mchid);
moreThanOne = true;
}
String mchkey = acc.getString(MCHKEY);
if (mchkey != null && !mchkey.equals("")) {
if (moreThanOne) sql.append(",");
sql.append("mchKey=?");
params.add(mchkey);
moreThanOne = true;
}
Integer wxpayon = acc.getInteger(WXPAYON);
if (wxpayon != null) {
if (moreThanOne) sql.append(",");
sql.append("wxPayOn=?");
params.add(wxpayon);
}
sql.append(" where id=?");
params.add(id);
update(sql.toString(), params, callback);
}
示例8: getEndpointStatus
import io.vertx.core.json.JsonArray; //导入方法依赖的package包/类
private void getEndpointStatus(RoutingContext rc) {
String label = rc.request().getParam("label");
JsonArray jsonEndpoints = new JsonArray();
for (Map.Entry<String, HEEndpointModel> entry : endpoints.entrySet()) {
jsonEndpoints.add(entry.getValue().toJson());
}
rc.response().setStatusCode(200).end(jsonEndpoints.encodePrettily());
}
示例9: encodeSyncMessage
import io.vertx.core.json.JsonArray; //导入方法依赖的package包/类
private Buffer encodeSyncMessage(List<GossipDigest> digests) {
Buffer buffer = Buffer.buffer();
JsonArray array = new JsonArray();
for (GossipDigest e : digests) {
array.add(Serializer.getInstance().encode(e).toString());
}
buffer.appendString(GossipMessageFactory.getInstance().makeMessage(MessageType.SYNC_MESSAGE, array.encode(), getCluster(), getSelf().ipAndPort()).encode());
return buffer;
}
示例10: getAdviceBody
import io.vertx.core.json.JsonArray; //导入方法依赖的package包/类
private JsonArray getAdviceBody() {
final JsonArray result = new JsonArray();
final JsonObject advBody = new JsonObject();
advBody.put("clientId", this.clientId);
advBody.put("advice", new JsonObject("{\"timeout\": 0}"));
advBody.put("channel", "/meta/connect");
advBody.put("id", "2");
advBody.put("connectionType", "long-polling");
result.add(advBody);
return result;
}
示例11: toJsonArray
import io.vertx.core.json.JsonArray; //导入方法依赖的package包/类
@SuppressWarnings("rawtypes")
public static JsonArray toJsonArray(Map row, String[] fields){
JsonArray j = new JsonArray();
for(String s: fields){
Object v = row.get(s);
if(v==null)
j.addNull();
else
j.add(v);
}
return j;
}
示例12: getBindValues
import io.vertx.core.json.JsonArray; //导入方法依赖的package包/类
private JsonArray getBindValues(Query query) {
JsonArray bindValues = new JsonArray();
for (Param<?> param : query.getParams().values()) {
Object value = convertToDatabaseType(param);
if(value==null){
bindValues.addNull();
}else{
bindValues.add(value);
}
}
return bindValues;
}
示例13: uploadNews
import io.vertx.core.json.JsonArray; //导入方法依赖的package包/类
public static JsonObject uploadNews(List<MsgNews> msgNewsList, Account mpAccount){
JsonObject rstObj = new JsonObject();
String accessToken = getAccessToken(mpAccount);
try{
JsonArray jsonArr = new JsonArray();
for(MsgNews news : msgNewsList){
JsonObject jsonObj = new JsonObject();
//上传图片素材
String mediaId = WxApi.uploadMedia(accessToken, MediaType.Image.toString(),news.getPicPath());
jsonObj.put("thumb_media_id", mediaId);
if(news.getAuthor() != null){
jsonObj.put("author", news.getAuthor());
}else{
jsonObj.put("author", "");
}
if(news.getTitle() != null){
jsonObj.put("title", news.getTitle());
}else{
jsonObj.put("title", "");
}
if(news.getFromurl() != null){
jsonObj.put("content_source_url", news.getFromurl());
}else{
jsonObj.put("content_source_url", "");
}
if(news.getBrief() != null){
jsonObj.put("digest", news.getBrief());
}else{
jsonObj.put("digest", "");
}
/*if(news.getShowpic() != null){
jsonObj.put("show_cover_pic", news.getShowpic());
}else{
jsonObj.put("show_cover_pic", "1");
}*/
jsonObj.put("content", news.getDescription());
jsonArr.add(jsonObj);
}
JsonObject postObj = new JsonObject();
postObj.put("articles", jsonArr);
rstObj = WxApi.httpsRequest(WxApi.getUploadNewsUrl(accessToken), HttpMethod.POST, postObj.toString());
}catch(Exception e){
e.printStackTrace();
}
return rstObj;
}
示例14: updateBase
import io.vertx.core.json.JsonArray; //导入方法依赖的package包/类
/**
* 更新账户基本公众号配置
*/
public void updateBase(JsonObject acc, Handler<Integer> callback) {
Integer id = acc.getInteger(ID);
if(id == null){
throw new IllegalArgumentException("Account ID cannot be null!!!");
}
StringBuilder sql = new StringBuilder("update awp_account set ");
JsonArray params = new JsonArray();
boolean moreThanOne = false;
String name = acc.getString(NAME);
if (name != null && !name.equals("")) {
sql.append("name=?");
params.add(name);
moreThanOne = true;
}
String appid = acc.getString(WXAPPID);
if (appid != null && !appid.equals("")) {
if (moreThanOne) sql.append(",");
sql.append("appid=?");
params.add(appid);
moreThanOne = true;
}
String appsecret = acc.getString(WXAPPSECRET);
if (appsecret != null && !appsecret.equals("")) {
if (moreThanOne) sql.append(",");
sql.append("appsecret=?");
params.add(appsecret);
moreThanOne = true;
}
String verify = acc.getString(VERIFY);
if (verify != null && !verify.equals("")) {
if (moreThanOne) sql.append(",");
sql.append("verify=?");
params.add(verify);
moreThanOne = true;
}
String email = acc.getString(EMAIL);
if (email != null && !email.equals("")) {
if (moreThanOne) sql.append(",");
sql.append("email=?");
params.add(email);
moreThanOne = true;
}
String password = acc.getString(PASSWORD);
if (password != null && !password.equals("")) {
if (moreThanOne) sql.append(",");
sql.append("password=?");
params.add(password);
}
sql.append(" where id=?");
params.add(id);
update(sql.toString(), params, callback);
}
示例15: getEndpointStatusById
import io.vertx.core.json.JsonArray; //导入方法依赖的package包/类
private void getEndpointStatusById(RoutingContext rc) {
String label = rc.request().getParam("label");
JsonArray jsonEndpoints = new JsonArray();
final String formattedLabel = label.replaceAll("%20", " ");
jsonEndpoints.add(endpoints.get(formattedLabel).toJson());
rc.response().setStatusCode(200).end(jsonEndpoints.encodePrettily());
}