Sha256: ceefd94d2d9b202c7e04e287dcd389cf491ac18b45eb42537668a2ff59b8ff06
Contents?: true
Size: 1.25 KB
Versions: 6
Compression:
Stored size: 1.25 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 { final JsonParser jsonParser = new JsonParser(); private 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
6 entries across 6 versions & 1 rubygems