Guest User

Untitled

a guest
Jan 16th, 2018
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.44 KB | None | 0 0
  1. import org.junit.Test;
  2. import java.util.Map;
  3.  
  4. import static io.restassured.path.json.JsonPath.from;
  5.  
  6. public class ConvertJsonToMap {
  7.  
  8. @Test
  9. public void myTest() {
  10.  
  11. String theJson = "{\n" +
  12. " \"order_confirmation_id\" : \"2TRTTMJ5\",\n" +
  13. " \"delivery_partner\":\"Deliv\",\n" +
  14. " \"delivery_pickup_address\" : {\n" +
  15. " \"location_name\" : \"Walmart Distribution Center\",\n" +
  16. " \"street\" : \"500 Golf Road\",\n" +
  17. " \"city\" : \"Elk Grove Village\",\n" +
  18. " \"state\" : \"IL\",\n" +
  19. " \"zipcode\" : \"60007\"\n" +
  20. " },\n" +
  21. " \"delivery_drop_off_address\" : {\n" +
  22. " \"customer_first_name\" : \"John\",\n" +
  23. " \"customer_last_name\" : \"Smith\",\n" +
  24. " \"street\" : \"2010 Mockingbird Lane\",\n" +
  25. " \"city\" : \"Elk Grove Village\",\n" +
  26. " \"state\" : \"IL\",\n" +
  27. " \"zipcode\" : \"60007\"\n" +
  28. " },\n" +
  29. " \"retailer\":\"Walmart\",\n" +
  30. " \"delivery_pickup_window\" : {\n" +
  31. " \"start_time\" : \"2017-11-18T16:00:00.000\",\n" +
  32. " \"end_time\" : \"2017-11-18T18:30:00.000\"\n" +
  33. " },\n" +
  34. " \"packages\" : [\n" +
  35. " {\n" +
  36. " \"package_id\" : \"14c6acf5-ba91-4b8a-99a2-6cebbe128967\",\n" +
  37. " \"weight\" : 2.5\n" +
  38. " },\n" +
  39. " {\n" +
  40. " \"package_id\" : \"dca86366-525d-4683-a363-a2c10eef8405\",\n" +
  41. " \"weight\" : 1.7\n" +
  42. " }\n" +
  43. " ],\n" +
  44. " \"garage_drop_user_id\":\"ea013bc5-4bb4-458c-ad58-1596b41a6fa6\",\n" +
  45. " \"garage_drop_user_myq_account_id\":\"907bccf6-9d34-4257-abd0-55e143e4a4ad\",\n" +
  46. " \n" +
  47. " \"delivery_devices\" : [\n" +
  48. " {\n" +
  49. " \"serial_number\":\"CG081F000A35\"\n" +
  50. " }\n" +
  51. " ]\n" +
  52. "}";
  53.  
  54. Map<String, ?> jsonAsArrayList = from(theJson).get("");
  55.  
  56. System.out.println(jsonAsArrayList);
  57.  
  58. }
  59.  
  60.  
  61. }
Add Comment
Please, Sign In to add comment