use of com.instagram.common.json.annotation.processor.uut.StrictListParseUUT in project ig-json-parser by Instagram.
the class DeserializeTest method malformedArrayEntry.
@Test
public void malformedArrayEntry() throws IOException, JSONException {
final List<Integer> integerList = Lists.newArrayList(1, null, 3, 4);
final int subIntValue = 30;
StringWriter stringWriter = new StringWriter();
ExtensibleJSONWriter writer = new ExtensibleJSONWriter(stringWriter);
writer.object().key(StrictListParseUUT.INTEGER_LIST_FIELD_NAME).array().extend(new ExtensibleJSONWriter.Extender() {
@Override
public void extend(ExtensibleJSONWriter writer) throws JSONException {
for (Integer integer : integerList) {
writer.value(integer);
}
}
}).endArray().key(StrictListParseUUT.SUBOBJECT_LIST_FIELD_NAME).object().key(StrictListParseUUT.SubobjectParseUUT.INT_FIELD_NAME).value(subIntValue).endObject().endObject();
String inputString = stringWriter.toString();
JsonParser jp = new JsonFactory().createParser(inputString);
jp.nextToken();
StrictListParseUUT uut = StrictListParseUUT__JsonHelper.parseFromJson(jp);
assertEquals(3, uut.integerListField.size());
assertEquals(1, uut.integerListField.get(0).intValue());
assertEquals(3, uut.integerListField.get(1).intValue());
assertEquals(4, uut.integerListField.get(2).intValue());
}
Aggregations