Package org.vertx.java.core.json

Examples of org.vertx.java.core.json.JsonObject.encode()


  private void handleDbMongo(final HttpServerRequest req) {
    findRandom(ThreadLocalRandom.current(), new Handler<Message<JsonObject>>() {
      @Override
      public void handle(Message<JsonObject> reply) {
        JsonObject world = getResultFromReply(reply);
        String result = world.encode();
        sendResponse(req, result);
      }
    });
  }
View Full Code Here


                    .add("chunkSize", chunkSize)
                    .add("uploadDate", new Date(uploadDate));

            if (filename != null) builder.add("filename", filename);
            if (contentType != null) builder.add("contentType", contentType);
            if (metadata != null) builder.add("metadata", JSON.parse(metadata.encode()));

            DBObject dbObject = builder.get();

            String bucket = jsonObject.getString("bucket", GridFS.DEFAULT_BUCKET);
            DBCollection collection = db.getCollection(bucket + ".files");
View Full Code Here

        // id is optional
        String id = body.getString(CONST_ID);

        client.prepareIndex(index, type, id)
                .setSource(source.encode())
                .execute(new ActionListener<IndexResponse>() {
                    @Override
                    public void onResponse(IndexResponse indexResponse) {
                        JsonObject reply = new JsonObject()
                                .putString(CONST_INDEX, indexResponse.getIndex())
View Full Code Here

        }

        // Set the query
        JsonObject query = body.getObject("query");
        if (query != null) {
            builder.setQuery(query.encode());
        }

        // Set the filter
        JsonObject filter = body.getObject("filter");
        if (filter != null) {
View Full Code Here

        }

        // Set the filter
        JsonObject filter = body.getObject("filter");
        if (filter != null) {
            builder.setPostFilter(filter.encode());
        }

        // Set facets
        JsonObject facets = body.getObject("facets");
        if (facets != null) {
View Full Code Here

        }

        // Set facets
        JsonObject facets = body.getObject("facets");
        if (facets != null) {
            builder.setFacets(facets.encode().getBytes(CHARSET_UTF8));
        }

        // Set search type
        String searchType = body.getString("search_type");
        if (searchType != null) {
View Full Code Here

            setContentType("application/json", "UTF-8");
            end(jsonArray.encode());
        } else if (json.isObject()) {
            JsonObject jsonObject = json.asObject();
            setContentType("application/json", "UTF-8");
            end(jsonObject.encode());
        }
    }

    public void jsonp(JsonElement json) {
        jsonp("callback", json);
View Full Code Here

            if (json.isArray()) {
                JsonArray jsonArray = json.asArray();
                body = jsonArray.encode();
            } else if (json.isObject()) {
                JsonObject jsonObject = json.asObject();
                body = jsonObject.encode();
            }
        }

        jsonp(callback, body);
    }
View Full Code Here

        yoke.use(new com.jetdrone.vertx.yoke.middleware.BodyParser());
        yoke.use(new Handler<YokeRequest>() {
            @Override
            public void handle(YokeRequest request) {
                assertNotNull(request.body());
                assertEquals(((JsonObject) request.body()).encode(), json.encode());
                request.response().end();
            }
        });

        Buffer body = new Buffer(json.encode());
View Full Code Here

                assertEquals(((JsonObject) request.body()).encode(), json.encode());
                request.response().end();
            }
        });

        Buffer body = new Buffer(json.encode());

        MultiMap headers = new CaseInsensitiveMultiMap();
        headers.add("content-type", "application/json");
        headers.add("content-length", Integer.toString(body.length()));
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.