本文整理了Java中org.codehaus.jackson.JsonNode.toString()
方法的一些代码示例,展示了JsonNode.toString()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。JsonNode.toString()
方法的具体详情如下:
包路径:org.codehaus.jackson.JsonNode
类名称:JsonNode
方法名:toString
[英]Note: marked as abstract to ensure all implementation classes define it properly.
[中]注意:标记为抽象以确保所有实现类都正确定义它。
代码示例来源:origin: kaaproject/kaa
@Test
public void testRemoveUuids() throws IOException {
AvroUtils.removeUuids(dataWithUUIDs);
String json = dataWithUUIDs.toString();
Assert.assertTrue("Generated json is not equal json without UUIDs", json.equals(data.toString()));
}
代码示例来源:origin: neo4j/neo4j
private void assertQueryGetsError( ServerControls server, String query, String error ) throws Throwable
{
HTTP.Response response = HTTP.POST( server.httpURI().resolve( "db/data/transaction/commit" ).toString(),
quotedJson( "{ 'statements': [ { 'statement': '" + query + "' } ] }" ) );
assertThat( response.get( "errors" ).toString(), containsString( error ) );
}
}
代码示例来源:origin: neo4j/neo4j
private void assertQueryGetsError( ServerControls server, String query, String error ) throws Throwable
{
HTTP.Response response = HTTP.POST( server.httpURI().resolve( "db/data/transaction/commit" ).toString(),
quotedJson( "{ 'statements': [ { 'statement': '" + query + "' } ] }" ) );
assertThat( response.get( "errors" ).toString(), containsString( error ) );
}
}
代码示例来源:origin: neo4j/neo4j
private void assertQueryGetsValue( ServerControls server, String query, long value ) throws Throwable
{
HTTP.Response response = HTTP.POST( server.httpURI().resolve( "db/data/transaction/commit" ).toString(),
quotedJson( "{ 'statements': [ { 'statement': '" + query + "' } ] }" ) );
assertEquals( "[]", response.get( "errors" ).toString() );
JsonNode result = response.get( "results" ).get( 0 );
assertEquals( "value", result.get( "columns" ).get( 0 ).asText() );
assertEquals( value, result.get( "data" ).get( 0 ).get( "row" ).get( 0 ).asLong() );
}
代码示例来源:origin: neo4j/neo4j
private void assertQueryGetsValue( ServerControls server, String query, long value ) throws Throwable
{
HTTP.Response response = HTTP.POST( server.httpURI().resolve( "db/data/transaction/commit" ).toString(),
quotedJson( "{ 'statements': [ { 'statement': '" + query + "' } ] }" ) );
assertEquals( "[]", response.get( "errors" ).toString() );
JsonNode result = response.get( "results" ).get( 0 );
assertEquals( "value", result.get( "columns" ).get( 0 ).asText() );
assertEquals( value, result.get( "data" ).get( 0 ).get( "row" ).get( 0 ).asLong() );
}
代码示例来源:origin: apache/incubator-gobblin
@Test(expectedExceptions = DataConversionException.class, expectedExceptionsMessageRegExp = "Input data does not have record.")
public void testFailureWithoutRecord() throws DataConversionException, IOException {
ObjectMapper objectMapper = new ObjectMapper();
// Build the input record without data
HashMap<String, Object> map = new HashMap<>();
Metadata md = new Metadata();
md.getRecordMetadata().put("test1", "test2");
map.put("rMd", md);
JsonNode jsonNode = objectMapper.valueToTree(map);
RecordWithMetadata<byte[]> inputRecord = new RecordWithMetadata<>(jsonNode.toString().getBytes(), null);
EnvelopedRecordWithMetadataToRecordWithMetadata converter = new EnvelopedRecordWithMetadataToRecordWithMetadata();
converter.convertRecord(null, inputRecord, null);
}
代码示例来源:origin: kaaproject/kaa
@Test
public void testInjectUuids() throws IOException {
String jsonWithUUIds = AvroUtils.injectUuids(data, avroSchema);
Assert.assertTrue("Generated json is not equal json with UUIDs", jsonWithUUIds.equals(dataWithUUIDs.toString()));
}
代码示例来源:origin: neo4j/neo4j
@Test
public void shouldWorkWithInjectableFromKernelExtension() throws Throwable
{
// When
try ( ServerControls server = createServer( MyProceduresUsingMyService.class ).newServer() )
{
// Then
HTTP.Response response = HTTP.POST( server.httpURI().resolve( "db/data/transaction/commit" ).toString(),
quotedJson( "{ 'statements': [ { 'statement': 'CALL hello' } ] }" ) );
assertEquals( "[]", response.get( "errors" ).toString() );
JsonNode result = response.get( "results" ).get( 0 );
assertEquals( "result", result.get( "columns" ).get( 0 ).asText() );
assertEquals( "world", result.get( "data" ).get( 0 ).get( "row" ).get( 0 ).asText() );
}
}
代码示例来源:origin: neo4j/neo4j
@Test
public void shouldLaunchWithDeclaredProcedures() throws Exception
{
// When
try ( ServerControls server = createServer( MyProcedures.class ).newServer() )
{
// Then
HTTP.Response response = HTTP.POST( server.httpURI().resolve( "db/data/transaction/commit" ).toString(),
quotedJson( "{ 'statements': [ { 'statement': 'CALL org.neo4j.harness.myProc' } ] }" ) );
JsonNode result = response.get( "results" ).get( 0 );
assertEquals( "someNumber", result.get( "columns" ).get( 0 ).asText() );
assertEquals( 1337, result.get( "data" ).get( 0 ).get( "row" ).get( 0 ).asInt() );
assertEquals( "[]", response.get( "errors" ).toString() );
}
}
代码示例来源:origin: neo4j/neo4j
@Test
public void shouldWorkWithInjectableFromKernelExtension() throws Throwable
{
// When
try ( ServerControls server = createServer( MyFunctionsUsingMyService.class ).newServer() )
{
// Then
HTTP.Response response = HTTP.POST( server.httpURI().resolve( "db/data/transaction/commit" ).toString(),
quotedJson( "{ 'statements': [ { 'statement': 'RETURN my.hello() AS result' } ] }" ) );
assertEquals( "[]", response.get( "errors" ).toString() );
JsonNode result = response.get( "results" ).get( 0 );
assertEquals( "result", result.get( "columns" ).get( 0 ).asText() );
assertEquals( "world", result.get( "data" ).get( 0 ).get( "row" ).get( 0 ).asText() );
}
}
代码示例来源:origin: neo4j/neo4j
@Test
public void shouldLaunchWithDeclaredFunctions() throws Exception
{
// When
try ( ServerControls server = createServer( MyFunctions.class ).newServer() )
{
// Then
HTTP.Response response = HTTP.POST( server.httpURI().resolve( "db/data/transaction/commit" ).toString(),
quotedJson(
"{ 'statements': [ { 'statement': 'RETURN org.neo4j.harness.myFunc() AS someNumber' } ] " +
"}" ) );
JsonNode result = response.get( "results" ).get( 0 );
assertEquals( "someNumber", result.get( "columns" ).get( 0 ).asText() );
assertEquals( 1337, result.get( "data" ).get( 0 ).get( "row" ).get( 0 ).asInt() );
assertEquals( "[]", response.get( "errors" ).toString() );
}
}
代码示例来源:origin: neo4j/neo4j
@Test
public void shouldLaunchWithDeclaredFunctions() throws Exception
{
// When
Class<MyFunctions> functionClass = MyFunctions.class;
try ( ServerControls server = createServer( functionClass ).newServer() )
{
// Then
HTTP.Response response = HTTP.POST( server.httpURI().resolve( "db/data/transaction/commit" ).toString(),
quotedJson(
"{ 'statements': [ { 'statement': 'RETURN org.neo4j.harness.myFunc() AS someNumber' } ] " +
"}" ) );
JsonNode result = response.get( "results" ).get( 0 );
assertEquals( "someNumber", result.get( "columns" ).get( 0 ).asText() );
assertEquals( 1337, result.get( "data" ).get( 0 ).get( "row" ).get( 0 ).asInt() );
assertEquals( "[]", response.get( "errors" ).toString() );
}
}
代码示例来源:origin: neo4j/neo4j
@Test
public void shouldHandleTemporalArraysUsingGraphResultDataContent() throws Exception
{
//Given
GraphDatabaseFacade db = server().getDatabase().getGraph();
ZonedDateTime date = ZonedDateTime.of( 1980, 3, 11, 0, 0,
0, 0, ZoneId.of( "Europe/Stockholm" ) );
try ( Transaction tx = db.beginTx() )
{
Node node = db.createNode( label( "N" ) );
node.setProperty( "dates", new ZonedDateTime[]{date} );
tx.success();
}
//When
HTTP.Response response = runQuery( "MATCH (n:N) RETURN n", "graph" );
//Then
assertEquals( 200, response.status() );
assertNoErrors( response );
JsonNode row = response.get( "results" ).get( 0 ).get( "data" ).get( 0 ).get( "graph" )
.get( "nodes" ).get( 0 ).get( "properties" ).get( "dates" ).get( 0 );
assertEquals( "\"1980-03-11T00:00+01:00[Europe/Stockholm]\"", row.toString() );
}
代码示例来源:origin: neo4j/neo4j
@Test
public void shouldHandleDurationArraysUsingGraphResultDataContent() throws Exception
{
//Given
GraphDatabaseFacade db = server().getDatabase().getGraph();
Duration duration = Duration.ofSeconds( 73 );
try ( Transaction tx = db.beginTx() )
{
Node node = db.createNode( label( "N" ) );
node.setProperty( "durations", new Duration[]{duration} );
tx.success();
}
//When
HTTP.Response response = runQuery( "MATCH (n:N) RETURN n", "graph" );
//Then
assertEquals( 200, response.status() );
assertNoErrors( response );
JsonNode row = response.get( "results" ).get( 0 ).get( "data" ).get( 0 ).get( "graph" )
.get("nodes").get( 0 ).get( "properties" ).get( "durations" ).get( 0 );
assertEquals( "\"PT1M13S\"", row.toString() );
}
代码示例来源:origin: neo4j/neo4j
@Test
public void shouldHandleDurationUsingGraphResultDataContent() throws Exception
{
//Given
GraphDatabaseFacade db = server().getDatabase().getGraph();
Duration duration = Duration.ofSeconds( 73 );
try ( Transaction tx = db.beginTx() )
{
Node node = db.createNode( label( "N" ) );
node.setProperty( "duration", duration );
tx.success();
}
//When
HTTP.Response response = runQuery( "MATCH (n:N) RETURN n", "graph" );
//Then
assertEquals( 200, response.status() );
assertNoErrors( response );
JsonNode row = response.get( "results" ).get( 0 ).get( "data" ).get( 0 ).get( "graph" )
.get("nodes").get( 0 ).get( "properties" ).get( "duration" );
assertEquals( "\"PT1M13S\"", row.toString() );
}
代码示例来源:origin: neo4j/neo4j
@Test
public void shouldHandleDurationArraysUsingRestResultDataContent() throws Exception
{
//Given
GraphDatabaseFacade db = server().getDatabase().getGraph();
Duration duration = Duration.ofSeconds( 73 );
try ( Transaction tx = db.beginTx() )
{
Node node = db.createNode( label( "N" ) );
node.setProperty( "durations", new Duration[]{duration} );
tx.success();
}
//When
HTTP.Response response = runQuery( "MATCH (n:N) RETURN n", "rest" );
//Then
assertEquals( 200, response.status() );
assertNoErrors( response );
JsonNode row = response.get( "results" ).get( 0 ).get( "data" ).get( 0 ).get( "rest" )
.get( 0 ).get( "data" ).get( "durations" ).get( 0 );
assertEquals( "\"PT1M13S\"", row.toString() );
}
代码示例来源:origin: neo4j/neo4j
@Test
public void shouldHandleTemporalArrays() throws Exception
{
//Given
GraphDatabaseFacade db = server().getDatabase().getGraph();
ZonedDateTime date = ZonedDateTime.of( 1980, 3, 11, 0, 0,
0, 0, ZoneId.of( "Europe/Stockholm" ) );
try ( Transaction tx = db.beginTx() )
{
Node node = db.createNode( label( "N" ) );
node.setProperty( "date", new ZonedDateTime[]{date} );
tx.success();
}
//When
HTTP.Response response = runQuery( "MATCH (n:N) RETURN n" );
//Then
assertEquals( 200, response.status() );
assertNoErrors( response );
JsonNode row = response.get( "results" ).get( 0 ).get( "data" ).get( 0 ).get( "row" ).get( 0 )
.get( "date" ).get( 0 );
assertEquals( "\"1980-03-11T00:00+01:00[Europe/Stockholm]\"", row.toString() );
}
代码示例来源:origin: neo4j/neo4j
public static void assertNoErrors( HTTP.Response response ) throws JsonParseException
{
assertEquals( "[]", response.get( "errors" ).toString() );
assertEquals( 0, response.get( "errors" ).size() );
}
}
代码示例来源:origin: neo4j/neo4j
@Test
public void shouldHandleDurationArrays() throws Exception
{
//Given
GraphDatabaseFacade db = server().getDatabase().getGraph();
Duration duration = Duration.ofSeconds( 73 );
try ( Transaction tx = db.beginTx() )
{
Node node = db.createNode( label( "N" ) );
node.setProperty( "duration", new Duration[]{duration} );
tx.success();
}
//When
HTTP.Response response = runQuery( "MATCH (n:N) RETURN n" );
//Then
assertEquals( 200, response.status() );
assertNoErrors( response );
JsonNode row = response.get( "results" ).get( 0 ).get( "data" ).get( 0 ).get( "row" ).get( 0 )
.get( "duration" ).get( 0 );
assertEquals( "\"PT1M13S\"", row.toString() );
}
代码示例来源:origin: neo4j/neo4j
@Test
public void shouldHandleDurationUsingRestResultDataContent() throws Exception
{
//Given
GraphDatabaseFacade db = server().getDatabase().getGraph();
Duration duration = Duration.ofSeconds( 73 );
try ( Transaction tx = db.beginTx() )
{
Node node = db.createNode( label( "N" ) );
node.setProperty( "duration", duration );
tx.success();
}
//When
HTTP.Response response = runQuery( "MATCH (n:N) RETURN n", "rest" );
//Then
assertEquals( 200, response.status() );
assertNoErrors( response );
JsonNode row = response.get( "results" ).get( 0 ).get( "data" ).get( 0 ).get( "rest" )
.get( 0 ).get( "data" ).get( "duration" );
assertEquals( "\"PT1M13S\"", row.toString() );
}
内容来源于网络,如有侵权,请联系作者删除!