use of org.pentaho.di.core.row.value.ValueMetaString in project pentaho-kettle by pentaho.
the class JsonInputTest method testChildBracketsNDots.
@Test
public void testChildBracketsNDots() throws Exception {
final String jsonInputField = getBasicTestJson();
testSimpleJsonPath("$.['store'].['bicycle'].['color']", new ValueMetaString("bcol"), new Object[][] { new Object[] { jsonInputField } }, new Object[][] { new Object[] { jsonInputField, "red" } });
}
use of org.pentaho.di.core.row.value.ValueMetaString in project pentaho-kettle by pentaho.
the class JsonInputTest method testJgdArray.
@Test
public void testJgdArray() throws Exception {
final String input = " { \"arr\": [ [ { \"a\": 1, \"b\": 1}, { \"a\": 1, \"b\": 2} ], [ {\"a\": 3, \"b\": 4 } ] ] }";
JsonInput jsonInput = createBasicTestJsonInput("$.arr", new ValueMetaString("array"), "json", new Object[] { input });
RowComparatorListener rowComparator = new RowComparatorListener(new Object[] { input, "[[{\"a\":1,\"b\":1},{\"a\":1,\"b\":2}],[{\"a\":3,\"b\":4}]]" });
rowComparator.setComparator(1, new JsonComparison());
jsonInput.addRowListener(rowComparator);
processRows(jsonInput, 2);
Assert.assertEquals(1, jsonInput.getLinesWritten());
}
use of org.pentaho.di.core.row.value.ValueMetaString in project pentaho-kettle by pentaho.
the class JsonInputTest method testNullProp.
@Test
public void testNullProp() throws Exception {
final String input = "{ \"obj\": [ { \"nval\": null, \"val\": 2 }, { \"val\": 1 } ] }";
JsonInput jsonInput = createBasicTestJsonInput("$.obj[?(@.nval)].val", new ValueMetaString("obj"), "json", new Object[] { input });
RowComparatorListener rowComparator = new RowComparatorListener(new Object[] { input, "2" });
rowComparator.setComparator(1, new JsonComparison());
jsonInput.addRowListener(rowComparator);
processRows(jsonInput, 2);
// in jsonpath 2.0->2.1, null value properties started being counted as existing
Assert.assertEquals(1, jsonInput.getLinesWritten());
}
use of org.pentaho.di.core.row.value.ValueMetaString in project pentaho-kettle by pentaho.
the class JsonInputTest method testChildBrackets.
@Test
public void testChildBrackets() throws Exception {
final String jsonInputField = getBasicTestJson();
testSimpleJsonPath("$.['store']['bicycle']['color']", new ValueMetaString("bcol"), new Object[][] { new Object[] { jsonInputField } }, new Object[][] { new Object[] { jsonInputField, "red" } });
}
use of org.pentaho.di.core.row.value.ValueMetaString in project pentaho-kettle by pentaho.
the class JsonOutputTest method createResultRowMetaInterface.
/**
* Creates a row meta interface for the fields that are defined by performing a getFields and by checking "Result
* filenames - Add filenames to result from "Text File Input" dialog.
*
* @return
*/
public RowMetaInterface createResultRowMetaInterface() {
RowMetaInterface rowMetaInterface = new RowMeta();
ValueMetaInterface[] valuesMeta = { new ValueMetaInteger("Id"), new ValueMetaString("State"), new ValueMetaString("City") };
for (int i = 0; i < valuesMeta.length; i++) {
rowMetaInterface.addValueMeta(valuesMeta[i]);
}
return rowMetaInterface;
}
Aggregations