Skip to content

Instantly share code, notes, and snippets.

@leonardocregis
Last active October 14, 2019 12:51
Show Gist options
  • Select an option

  • Save leonardocregis/4d973a20caec78c3f3ee9a46fbd781c4 to your computer and use it in GitHub Desktop.

Select an option

Save leonardocregis/4d973a20caec78c3f3ee9a46fbd781c4 to your computer and use it in GitHub Desktop.
import com.fasterxml.jackson.databind.ObjectMapper;
import java.io.IOException;
import org.junit.Test;
import static org.junit.Assert.assertNotNull;
public class ResponseTest {
@Test
public void testParseJson() throws IOException {
String jsonData = "{\n" +
" \"total\": 100," +
" \"val\": 2000," +
"}";
ObjectMapper objectMapper = new ObjectMapper();
TT080DgiiOrderResponse response = objectMapper.readValue(jsonData, JsonMapped.class);
assertNotNull(response);
}
}
.....
import com.fasterxml.jackson.annotation.JsonProperty;
public class JsonMapped {
@JsonProperty("total")
private Long total
@JsonProperty("val")
private Long value;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment