APISonar


org.rapidoid.data.JSON.stringify

> org > rapidoid > data > JSON > stringify
org APIs rapidoid APIs data APIs JSON APIs stringify APIs

Example 1
public Channel writeJSON(Object value) {
		JSON.stringify(value, output.asOutputStream());
		return this;
	}
Example 2
public void testBasicConfig() {
		Conf.ROOT.setFilenameBase("beans");

		Map<String, Platform> platforms = Conf.ROOT.sub("platforms").toMap(Platform.class);

		verify(JSON.stringify(platforms));
	}
Example 3
protected void writeJsonBody(MaybeReq req, Channel ctx, Object value) {
		writeContentTypeHeader(ctx, MediaType.JSON);

		ReusableWritable out = Msc.locals().jsonRenderingStream();
		JSON.stringify(value, out);

		HttpIO.INSTANCE.writeContentLengthHeader(ctx, out.size());
		HttpIO.INSTANCE.closeHeaders(req, ctx.output());
		ctx.write(out.array(), 0, out.size());
	}
Example 4
public void testTUUIDasJSON() {
		String json = "{\"x\":\"AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA\"}";
		eq(JSON.stringify(U.map("x", new TUUID(0, 0, 0))), json);
		eq(JSON.parse(json), U.map("x", "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"));
		eq(JSON.parse(json, BeanWithId.class).x, new TUUID(0, 0, 0));
	}
Example 5
public void testRuntimeError() {
		initAPI();

		HttpResp resp = Self.get("/inc/d9g").execute();

		eq(resp.code(), 500);
		eq(resp.body(), JSON.stringify(U.map(
			"error", "For input string: \"d9g\"",
			"code", 500,
			"status", "Internal Server Error"
		)));
	}
Example 6
public void testNotFound() {
		initAPI();

		HttpResp resp = Self.get("/foo/baz").execute();

		eq(resp.code(), 404);
		eq(resp.body(), JSON.stringify(U.map(
			"error", "The requested resource could not be found!",
			"code", 404,
			"status", "Not Found"
		)));
	}
Example 7
public void testJSONParsingWithoutJsonHeaderPUT() {
		// simply return the same object
		On.put("/movie").json((Movie m) -> m);

		Movie movie = new Movie("test title", 1999);
		onlyPut("/movie", JSON.stringify(movie));
	}