use of com.amazon.ion.IonValue in project jackson-dataformats-binary by FasterXML.
the class IonValueDeserializerTest method shouldBeAbleToDeserializeNullList.
@Test
public void shouldBeAbleToDeserializeNullList() throws Exception {
IonValue ion = ion("{c:null.list}");
IonValueData data = ION_VALUE_MAPPER.readValue(ion, IonValueData.class);
assertEquals(1, data.getAllData().size());
assertEquals(SYSTEM.newNullList(), data.getAllData().get("c"));
}
use of com.amazon.ion.IonValue in project jackson-dataformats-binary by FasterXML.
the class IonValueDeserializerTest method shouldBeAbleToDeserializeIncludingNullList.
@Test
public void shouldBeAbleToDeserializeIncludingNullList() throws Exception {
IonValue ion = ion("{a:1, b:2, c:null.list}");
IonValueData data = ION_VALUE_MAPPER.readValue(ion, IonValueData.class);
assertEquals(3, data.getAllData().size());
assertEquals(ion("1"), data.getAllData().get("a"));
assertEquals(ion("2"), data.getAllData().get("b"));
assertEquals(ion("null.list"), data.getAllData().get("c"));
}
use of com.amazon.ion.IonValue in project jackson-dataformats-binary by FasterXML.
the class DataBindReadTest method testFromIon.
/**
* Test reading an IonValue, which also happens to not be at the top level.
*/
@Test
public void testFromIon() throws IOException {
IonObjectMapper m = new IonObjectMapper();
IonSystem ion = IonSystemBuilder.standard().build();
IonValue value = ion.singleValue("{payload: {'a': bc, b : '14' }}");
MyBean bean = m.readValue(((IonStruct) value).get("payload"), MyBean.class);
assertEquals("bc", bean.a);
assertEquals(14, bean.b);
}
use of com.amazon.ion.IonValue in project ion-hive-serde by amzn.
the class IonStructToMapObjectInspector method getMap.
@Override
public Map<?, ?> getMap(final Object data) {
if (IonUtil.isIonNull((IonValue) data)) {
return null;
}
final IonStruct struct = (IonStruct) data;
// sets the initial size of the map to avoid growing as it's immutable while using the default HashMap load
// factor to maintain the same collision performance
final int size = (int) Math.ceil(struct.size() / DEFAULT_LOAD_FACTOR);
final Map<String, IonValue> map = new HashMap<>(size, DEFAULT_LOAD_FACTOR);
for (IonValue v : struct) {
map.put(v.getFieldName(), v);
}
return map;
}
use of com.amazon.ion.IonValue in project jackson-dataformats-binary by FasterXML.
the class SerializationAnnotationsTest method testNativeTypeIdsCanBeDisabledOnWrite.
@Test
public void testNativeTypeIdsCanBeDisabledOnWrite() throws Exception {
IonObjectMapper mapper = IonObjectMapper.builderForTextualWriters().disable(IonGenerator.Feature.USE_NATIVE_TYPE_ID).build();
IonValue subclassAsIon = mapper.writeValueAsIonValue(subclass);
assertEqualIonValues(SUBCLASS_TYPED_AS_PROPERTY, subclassAsIon);
BaseClass roundTripInstance = mapper.readValue(subclassAsIon, BaseClass.class);
assertCorrectlyTypedAndFormed(subclass, roundTripInstance);
}
Aggregations