@Test public void testWithNestedObject() throws Exception { Vertex vertex = function.map("{\"someObj\": {\"a\": 1, \"b\": [true], \"c\":" + "{\"d\": 1}}}"); expectedValue.setProperty("someObj", "{\"a\":1,\"b\":[true],\"c\":{\"d\":1}}"); assertVertexEquals(expectedValue, vertex); }
@Override public EPGMVertex map(String jsonString) throws Exception { JSONObject jsonVertex = new JSONObject(jsonString); Properties properties = reuse.getProperties(); if (properties == null) { properties = Properties.create(); reuse.setProperties(properties); } properties.clear(); for (Iterator it = jsonVertex.keys(); it.hasNext();) { String key = (String) it.next(); PropertyValue propertyValue = getPropertyValue(jsonVertex, key); properties.set(key, propertyValue); } return reuse; }
MinimalJsonToVertex implements MapFunction<String, EPGMVertex> { @Override public EPGMVertex map(String jsonString) throws Exception { JSONObject jsonVertex = new JSONObject(jsonString); Properties properties = reuse.getProperties(); if (properties == null) { properties = Properties.create(); reuse.setProperties(properties); } properties.clear(); for (Iterator it = jsonVertex.keys(); it.hasNext();) { String key = (String) it.next(); PropertyValue propertyValue = getPropertyValue(jsonVertex, key); properties.set(key, propertyValue); } return reuse; } }
MinimalJsonToVertex implements MapFunction<String, EPGMVertex> { @Override public EPGMVertex map(String jsonString) throws Exception { JSONObject jsonVertex = new JSONObject(jsonString); Properties properties = reuse.getProperties(); if (properties == null) { properties = Properties.create(); reuse.setProperties(properties); } properties.clear(); for (Iterator it = jsonVertex.keys(); it.hasNext();) { String key = (String) it.next(); PropertyValue propertyValue = getPropertyValue(jsonVertex, key); properties.set(key, propertyValue); } return reuse; } MinimalJsonToVertex(VertexFactory<EPGMVertex> vertexFactory); }
MinimalJsonToVertex implements MapFunction<String, EPGMVertex> { @Override public EPGMVertex map(String jsonString) throws Exception { JSONObject jsonVertex = new JSONObject(jsonString); Properties properties = reuse.getProperties(); if (properties == null) { properties = Properties.create(); reuse.setProperties(properties); } properties.clear(); for (Iterator it = jsonVertex.keys(); it.hasNext();) { String key = (String) it.next(); PropertyValue propertyValue = getPropertyValue(jsonVertex, key); properties.set(key, propertyValue); } return reuse; } MinimalJsonToVertex(VertexFactory<EPGMVertex> vertexFactory); @Override EPGMVertex map(String jsonString); }
MinimalJsonToVertex implements MapFunction<String, EPGMVertex> { @Override public EPGMVertex map(String jsonString) throws Exception { JSONObject jsonVertex = new JSONObject(jsonString); Properties properties = reuse.getProperties(); if (properties == null) { properties = Properties.create(); reuse.setProperties(properties); } properties.clear(); for (Iterator it = jsonVertex.keys(); it.hasNext();) { String key = (String) it.next(); PropertyValue propertyValue = getPropertyValue(jsonVertex, key); properties.set(key, propertyValue); } return reuse; } MinimalJsonToVertex(VertexFactory<EPGMVertex> vertexFactory); @Override EPGMVertex map(String jsonString); static final String JSON_VERTEX_LABEL; }