use of com.hazelcast.internal.json.JsonArray in project hazelcast by hazelcast.
the class JsonParser_Test method parse_failsOnTooDeeplyNestedMixedObject.
@Test
public void parse_failsOnTooDeeplyNestedMixedObject() {
JsonValue value = new JsonObject();
for (int i = 0; i < 1001; i++) {
value = i % 2 == 0 ? new JsonArray().add(value) : new JsonObject().add("foo", value);
}
final String input = value.toString();
ParseException exception = assertException(ParseException.class, new RunnableEx() {
public void run() throws IOException {
parser.parse(input);
}
});
assertEquals("Nesting too deep at 1:4002", exception.getMessage());
}
use of com.hazelcast.internal.json.JsonArray in project hazelcast by hazelcast.
the class Json_Test method array_long.
@Test
public void array_long() {
assertEquals(new JsonArray().add(23l), Json.array(new long[] { 23l }));
assertEquals(new JsonArray().add(23l).add(42l), Json.array(new long[] { 23l, 42l }));
}
use of com.hazelcast.internal.json.JsonArray in project hazelcast by hazelcast.
the class PrettyPrint_Test method testIndentWithSpaces_nestedArray.
@Test
public void testIndentWithSpaces_nestedArray() throws IOException {
new JsonArray().add(23).add(new JsonArray().add(42)).writeTo(output, indentWithSpaces(2));
assertEquals("[\n 23,\n [\n 42\n ]\n]", output.toString());
}
use of com.hazelcast.internal.json.JsonArray in project hazelcast by hazelcast.
the class PrettyPrint_Test method testIndentWithTabs.
@Test
public void testIndentWithTabs() throws IOException {
new JsonArray().add(23).add(42).writeTo(output, indentWithTabs());
assertEquals("[\n\t23,\n\t42\n]", output.toString());
}
use of com.hazelcast.internal.json.JsonArray in project hazelcast by hazelcast.
the class GcpComputeApi method zones.
List<String> zones(String project, String region, String accessToken) {
String url = String.format("%s/compute/v1/projects/%s/regions/%s?alt=json&fields=zones", endpoint, project, region);
String response = RestClient.create(url).withHeader("Authorization", String.format("OAuth %s", accessToken)).get().getBody();
JsonArray zoneUrls = toJsonArray(Json.parse(response).asObject().get("zones"));
List<String> zones = new ArrayList<>();
for (JsonValue value : zoneUrls) {
zones.add(lastPartOf(value.asString(), "/"));
}
return zones;
}
Aggregations