Skip to content

Instantly share code, notes, and snippets.

@brianm
Last active December 25, 2015 22:05
Show Gist options
  • Save brianm/5cd6618facd4eb6c41a3 to your computer and use it in GitHub Desktop.
Save brianm/5cd6618facd4eb6c41a3 to your computer and use it in GitHub Desktop.
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