@ComponentProfile(summary="Output the first resultset as JSON", tag="json,jdbc") public class JdbcJsonOutput extends StyledResultTranslatorImp
ResultSetTranslator
that outputs the first result set as json.
Takes the first result set and writes out each row as part of a json array. You should use this output implementation if you
are executing a SELECT via JdbcDataQueryService
.
[{ "firstName": "John",
"lastName": "Doe"
},
{
"firstName": "Anna",
"lastName": "Smith"
},
{
"firstName": "Peter",
"lastName": "Jones"
}]
In the adapter configuration file this class is aliased as jdbc-json-first-resultset-output which is the preferred alternative to the fully qualified classname when building your configuration.
StyledResultTranslatorImp.ColumnStyle
Modifier and Type | Field and Description |
---|---|
protected com.fasterxml.jackson.databind.ObjectMapper |
mapper |
log
Constructor and Description |
---|
JdbcJsonOutput() |
Modifier and Type | Method and Description |
---|---|
void |
translate(JdbcResult source,
AdaptrisMessage target) |
JdbcJsonOutput |
withColumnStyle(StyledResultTranslatorImp.ColumnStyle b) |
protected void |
writeResultSet(JdbcResultSet result,
com.fasterxml.jackson.core.JsonGenerator generator) |
getColumnNameStyle, setColumnNameStyle, withColumnNameStyle
prepare
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
close, init, start, stop
public void translate(JdbcResult source, AdaptrisMessage target) throws java.sql.SQLException, ServiceException
java.sql.SQLException
ServiceException
protected void writeResultSet(JdbcResultSet result, com.fasterxml.jackson.core.JsonGenerator generator) throws java.io.IOException
java.io.IOException
public JdbcJsonOutput withColumnStyle(StyledResultTranslatorImp.ColumnStyle b)