use of org.yuanheng.cookjson.CookJsonGenerator in project jaqy by Teradata.
the class JsonExporter method export.
@Override
public long export(JaqyResultSet rs, JaqyInterpreter interpreter) throws Exception {
JsonProvider provider = new CookJsonProvider();
CookJsonGenerator g = null;
HashMap<String, Object> config = new HashMap<String, Object>();
switch(m_format) {
case Text:
{
config.put(CookJsonProvider.FORMAT, CookJsonProvider.FORMAT_JSON);
if (m_pretty)
config.put(JsonGenerator.PRETTY_PRINTING, Boolean.TRUE);
switch(m_binaryFormat) {
case Base64:
config.put(CookJsonProvider.BINARY_FORMAT, CookJsonProvider.BINARY_FORMAT_BASE64);
break;
case Hex:
config.put(CookJsonProvider.BINARY_FORMAT, CookJsonProvider.BINARY_FORMAT_HEX);
break;
}
g = (CookJsonGenerator) provider.createGeneratorFactory(config).createGenerator(m_out);
break;
}
case Bson:
config.put(CookJsonProvider.FORMAT, CookJsonProvider.FORMAT_BSON);
g = (CookJsonGenerator) provider.createGeneratorFactory(config).createGenerator(m_os);
break;
}
long count = JsonUtils.print(interpreter.getGlobals(), g, rs, 0);
g.close();
return count;
}
use of org.yuanheng.cookjson.CookJsonGenerator in project jaqy by Teradata.
the class JsonPrinter method print.
@Override
public long print(JaqyResultSet rs, PrintWriter pw, long limit, JaqyInterpreter interpreter) throws Exception {
JsonProvider provider = new CookJsonProvider();
HashMap<String, Object> config = new HashMap<String, Object>();
config.put(CookJsonProvider.FORMAT, CookJsonProvider.FORMAT_JSON);
if (m_pretty)
config.put(JsonGenerator.PRETTY_PRINTING, Boolean.TRUE);
switch(m_binaryFormat) {
case Base64:
config.put(CookJsonProvider.BINARY_FORMAT, CookJsonProvider.BINARY_FORMAT_BASE64);
break;
case Hex:
config.put(CookJsonProvider.BINARY_FORMAT, CookJsonProvider.BINARY_FORMAT_HEX);
break;
}
CookJsonGenerator g = (CookJsonGenerator) provider.createGeneratorFactory(config).createGenerator(pw);
long count = JsonUtils.print(interpreter.getGlobals(), g, rs, limit);
pw.println();
return count;
}
Aggregations