src/main/java/org/embulk/input/jdbc/getter/StringColumnGetter.java in embulk-input-jdbc-0.6.4 vs src/main/java/org/embulk/input/jdbc/getter/StringColumnGetter.java in embulk-input-jdbc-0.7.0
- old
+ new
@@ -2,16 +2,21 @@
import java.sql.ResultSet;
import java.sql.SQLException;
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 StringColumnGetter
extends AbstractColumnGetter
{
+ final JsonParser jsonParser = new JsonParser();
+
private String value;
public StringColumnGetter(PageBuilder to, Type toType)
{
super(to, toType);
@@ -51,9 +56,22 @@
} catch (NumberFormatException e) {
super.doubleColumn(column);
return;
}
to.setDouble(column, d);
+ }
+
+ @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)
{