Java Code Examples for groovy.json.JsonBuilder
The following examples show how to use
groovy.json.JsonBuilder.
These examples are extracted from open source projects.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source Project: tinkerpop Author: apache File: AbstractGraphSONMessageSerializerV1d0.java License: Apache License 2.0 | 5 votes |
@Override public void serialize(final JsonBuilder json, final JsonGenerator jsonGenerator, final SerializerProvider serializerProvider) throws IOException, JsonGenerationException { // the JSON from the builder will already be started/ended as array or object...just need to surround it // with appropriate chars to fit into the serialization pattern. jsonGenerator.writeRaw(":"); jsonGenerator.writeRaw(json.toString()); jsonGenerator.writeRaw(","); }
Example #2
Source Project: tinkerpop Author: apache File: AbstractGraphSONMessageSerializerV2d0.java License: Apache License 2.0 | 5 votes |
public GremlinServerModule() { super("graphson-gremlin-server"); // SERIALIZERS addSerializer(JsonBuilder.class, new JsonBuilderJacksonSerializer()); addSerializer(ResponseMessage.class, new ResponseMessageSerializer()); addSerializer(RequestMessage.class, new RequestMessageSerializer()); //DESERIALIZERS addDeserializer(ResponseMessage.class, new ResponseMessageDeserializer()); addDeserializer(RequestMessage.class, new RequestMessageDeserializer()); }
Example #3
Source Project: tinkerpop Author: apache File: AbstractGraphSONMessageSerializerV2d0.java License: Apache License 2.0 | 5 votes |
@Override public void serialize(final JsonBuilder json, final JsonGenerator jsonGenerator, final SerializerProvider serializerProvider) throws IOException, JsonGenerationException { // the JSON from the builder will already be started/ended as array or object...just need to surround it // with appropriate chars to fit into the serialization pattern. jsonGenerator.writeRaw(":"); jsonGenerator.writeRaw(json.toString()); jsonGenerator.writeRaw(","); }
Example #4
Source Project: tinkerpop Author: apache File: GremlinDriverIntegrateTest.java License: Apache License 2.0 | 5 votes |
@Test public void shouldDeserializeWithCustomClassesV1() throws Exception { final Map<String, Object> m = new HashMap<>(); m.put("custom", Collections.singletonList(String.format("%s;%s", JsonBuilder.class.getCanonicalName(), JsonBuilderGryoSerializer.class.getCanonicalName()))); final GryoMessageSerializerV1d0 serializer = new GryoMessageSerializerV1d0(); serializer.configure(m, null); final Cluster cluster = TestClientFactory.build().serializer(serializer).create(); final Client client = cluster.connect(); final List<Result> json = client.submit("b = new groovy.json.JsonBuilder();b.people{person {fname 'stephen'\nlname 'mallette'}};b").all().join(); assertEquals("{\"people\":{\"person\":{\"fname\":\"stephen\",\"lname\":\"mallette\"}}}", json.get(0).getString()); cluster.close(); }
Example #5
Source Project: tinkerpop Author: apache File: GremlinDriverIntegrateTest.java License: Apache License 2.0 | 5 votes |
@Test public void shouldDeserializeWithCustomClassesV3() throws Exception { final Map<String, Object> m = new HashMap<>(); m.put("custom", Collections.singletonList(String.format("%s;%s", JsonBuilder.class.getCanonicalName(), JsonBuilderGryoSerializer.class.getCanonicalName()))); final GryoMessageSerializerV3d0 serializer = new GryoMessageSerializerV3d0(); serializer.configure(m, null); final Cluster cluster = TestClientFactory.build().serializer(serializer).create(); final Client client = cluster.connect(); final List<Result> json = client.submit("b = new groovy.json.JsonBuilder();b.people{person {fname 'stephen'\nlname 'mallette'}};b").all().join(); assertEquals("{\"people\":{\"person\":{\"fname\":\"stephen\",\"lname\":\"mallette\"}}}", json.get(0).getString()); cluster.close(); }
Example #6
Source Project: pipeline-aws-plugin Author: jenkinsci File: JsonUtils.java License: Apache License 2.0 | 4 votes |
public static String toString(Object object) { return (new JsonBuilder(object)).toString(); }
Example #7
Source Project: groovy Author: apache File: YamlBuilder.java License: Apache License 2.0 | 4 votes |
public YamlBuilder() { this.jsonBuilder = new JsonBuilder(); }
Example #8
Source Project: tinkerpop Author: apache File: JsonBuilderGryoSerializer.java License: Apache License 2.0 | 4 votes |
@Override public void write(final Kryo kryo, final Output output, final JsonBuilder jsonBuilder) { output.writeString(jsonBuilder.toString()); }
Example #9
Source Project: tinkerpop Author: apache File: JsonBuilderGryoSerializer.java License: Apache License 2.0 | 4 votes |
@Override public JsonBuilder read(final Kryo kryo, final Input input, final Class<JsonBuilder> jsonBuilderClass) { final String jsonString = input.readString(); return new JsonBuilder(slurper.parseText(jsonString)); }
Example #10
Source Project: tinkerpop Author: apache File: AbstractGraphSONMessageSerializerV1d0.java License: Apache License 2.0 | 4 votes |
public GremlinServerModule() { super("graphson-gremlin-server"); addSerializer(JsonBuilder.class, new JsonBuilderJacksonSerializer()); addSerializer(ResponseMessage.class, new ResponseMessageSerializer()); }
Example #11
Source Project: tinkerpop Author: apache File: AbstractGraphSONMessageSerializerV1d0.java License: Apache License 2.0 | 4 votes |
public JsonBuilderJacksonSerializer() { super(JsonBuilder.class); }
Example #12
Source Project: tinkerpop Author: apache File: AbstractGraphSONMessageSerializerV2d0.java License: Apache License 2.0 | 4 votes |
public JsonBuilderJacksonSerializer() { super(JsonBuilder.class); }
Example #13
Source Project: tinkerpop Author: apache File: GremlinDriverIntegrateTest.java License: Apache License 2.0 | 4 votes |
/** * Configure specific Gremlin Server settings for specific tests. */ @Override public Settings overrideSettings(final Settings settings) { final String nameOfTest = name.getMethodName(); switch (nameOfTest) { case "shouldAliasTraversalSourceVariables": case "shouldAliasTraversalSourceVariablesInSession": try { final String p = Storage.toPath(TestHelper.generateTempFileFromResource( GremlinDriverIntegrateTest.class, "generate-shouldRebindTraversalSourceVariables.groovy", "")); final Map<String,Object> m = new HashMap<>(); m.put("files", Collections.singletonList(p)); settings.scriptEngines.get("gremlin-groovy").plugins.put(ScriptFileGremlinPlugin.class.getName(), m); } catch (Exception ex) { throw new RuntimeException(ex); } break; case "shouldFailWithBadClientSideSerialization": final List<String> custom = Arrays.asList( JsonBuilder.class.getName() + ";" + JsonBuilderGryoSerializer.class.getName(), java.awt.Color.class.getName()); settings.serializers.stream().filter(s -> s.config.containsKey("custom")) .findFirst().get().config.put("custom", custom); break; case "shouldExecuteScriptInSessionOnTransactionalGraph": case "shouldExecuteSessionlessScriptOnTransactionalGraph": case "shouldExecuteScriptInSessionOnTransactionalWithManualTransactionsGraph": case "shouldExecuteInSessionAndSessionlessWithoutOpeningTransaction": case "shouldManageTransactionsInSession": deleteDirectory(new File("/tmp/neo4j")); settings.graphs.put("graph", "conf/neo4j-empty.properties"); break; case "shouldRequireAliasedGraphVariablesInStrictTransactionMode": settings.strictTransactionManagement = true; break; case "shouldAliasGraphVariablesInStrictTransactionMode": settings.strictTransactionManagement = true; deleteDirectory(new File("/tmp/neo4j")); settings.graphs.put("graph", "conf/neo4j-empty.properties"); break; case "shouldProcessSessionRequestsInOrderAfterTimeout": settings.evaluationTimeout = 250; settings.threadPoolWorker = 1; break; case "shouldProcessTraversalInterruption": case "shouldProcessEvalInterruption": settings.evaluationTimeout = 1500; break; } return settings; }
Example #14
Source Project: jenkernetes Author: GoogleCloudPlatform File: KubernetesClient.java License: Apache License 2.0 | 4 votes |
private static StringEntity toEntity(Object payload) throws UnsupportedEncodingException{ return new StringEntity(new JsonBuilder(payload).toString()); }