Sha256: 36e685221dbb06180be54a398bcf8f63fcb29750d8c95adf3cad5af90fa8e6af
Contents?: true
Size: 1.26 KB
Versions: 12
Compression:
Stored size: 1.26 KB
Contents
package org.embulk.input.jdbc.getter; import java.sql.ResultSet; import java.sql.SQLException; import org.embulk.input.jdbc.getter.AbstractColumnGetter; import org.embulk.spi.Column; import org.embulk.spi.PageBuilder; import org.embulk.spi.json.JsonParseException; import org.embulk.spi.json.JsonParser; import org.embulk.spi.type.Type; import org.embulk.spi.type.Types; import org.msgpack.value.Value; public class JsonColumnGetter extends AbstractColumnGetter { protected final JsonParser jsonParser = new JsonParser(); protected String value; public JsonColumnGetter(PageBuilder to, Type toType) { super(to, toType); } @Override protected void fetch(ResultSet from, int fromIndex) throws SQLException { value = from.getString(fromIndex); } @Override protected Type getDefaultToType() { return Types.JSON; } @Override public void jsonColumn(Column column) { Value v; try { v = jsonParser.parse(value); } catch (JsonParseException e) { super.jsonColumn(column); return; } to.setJson(column, v); } @Override public void stringColumn(Column column) { to.setString(column, value); } }
Version data entries
12 entries across 12 versions & 2 rubygems