Advertisement
Guest User

Untitled

a guest
Sep 16th, 2019
135
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.71 KB | None | 0 0
  1. import com.fasterxml.jackson.databind.ObjectMapper;
  2. import java.io.IOException;
  3.  
  4. import org.junit.Test;
  5.  
  6. import static org.junit.Assert.assertNotNull;
  7.  
  8. public class TT080DgiiOrderResponseTest {
  9.  
  10. @Test
  11. public void testParseJson() throws IOException {
  12. String jsonData = "{\n" +
  13. " \"total\": 100," +
  14. " \"val\": 2000," +
  15. "}";
  16.  
  17. ObjectMapper objectMapper = new ObjectMapper();
  18. TT080DgiiOrderResponse response = objectMapper.readValue(jsonData, JsonMapped.class);
  19. assertNotNull(response);
  20. }
  21.  
  22. }
  23.  
  24. .....
  25. import com.fasterxml.jackson.annotation.JsonProperty;
  26.  
  27. public class JsonMapped {
  28. @JsonProperty("total")
  29. private Long total
  30. @JsonProperty("val")
  31. private Long value;
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement