Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
package org.skife.muckery.jackson;
import com.fasterxml.jackson.core.JsonParser;
import com.fasterxml.jackson.databind.MappingIterator;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.junit.Test;
import static org.assertj.core.api.Assertions.assertThat;
public class ObjectStreamTest {
@Test
public void testFoo() throws Exception {
ObjectMapper mapper = new ObjectMapper();
String json = "[{\"a\":0},{\"a\":1},{\"a\":2}]";
MappingIterator<Thing> itty = mapper.readerFor(Thing.class).readValues(json);
Thing zero = itty.next();
assertThat(zero.a).isEqualTo(0);
Thing one = itty.next();
assertThat(one.a).isEqualTo(1);
Thing two = itty.next();
assertThat(two.a).isEqualTo(2);
assertThat(itty.hasNext()).isFalse();
}
public static class Thing
{
public int a;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.