Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import org.junit.Test;
- import java.util.Map;
- import static io.restassured.path.json.JsonPath.from;
- public class ConvertJsonToMap {
- @Test
- public void myTest() {
- String theJson = "{\n" +
- " \"order_confirmation_id\" : \"2TRTTMJ5\",\n" +
- " \"delivery_partner\":\"Deliv\",\n" +
- " \"delivery_pickup_address\" : {\n" +
- " \"location_name\" : \"Walmart Distribution Center\",\n" +
- " \"street\" : \"500 Golf Road\",\n" +
- " \"city\" : \"Elk Grove Village\",\n" +
- " \"state\" : \"IL\",\n" +
- " \"zipcode\" : \"60007\"\n" +
- " },\n" +
- " \"delivery_drop_off_address\" : {\n" +
- " \"customer_first_name\" : \"John\",\n" +
- " \"customer_last_name\" : \"Smith\",\n" +
- " \"street\" : \"2010 Mockingbird Lane\",\n" +
- " \"city\" : \"Elk Grove Village\",\n" +
- " \"state\" : \"IL\",\n" +
- " \"zipcode\" : \"60007\"\n" +
- " },\n" +
- " \"retailer\":\"Walmart\",\n" +
- " \"delivery_pickup_window\" : {\n" +
- " \"start_time\" : \"2017-11-18T16:00:00.000\",\n" +
- " \"end_time\" : \"2017-11-18T18:30:00.000\"\n" +
- " },\n" +
- " \"packages\" : [\n" +
- " {\n" +
- " \"package_id\" : \"14c6acf5-ba91-4b8a-99a2-6cebbe128967\",\n" +
- " \"weight\" : 2.5\n" +
- " },\n" +
- " {\n" +
- " \"package_id\" : \"dca86366-525d-4683-a363-a2c10eef8405\",\n" +
- " \"weight\" : 1.7\n" +
- " }\n" +
- " ],\n" +
- " \"garage_drop_user_id\":\"ea013bc5-4bb4-458c-ad58-1596b41a6fa6\",\n" +
- " \"garage_drop_user_myq_account_id\":\"907bccf6-9d34-4257-abd0-55e143e4a4ad\",\n" +
- " \n" +
- " \"delivery_devices\" : [\n" +
- " {\n" +
- " \"serial_number\":\"CG081F000A35\"\n" +
- " }\n" +
- " ]\n" +
- "}";
- Map<String, ?> jsonAsArrayList = from(theJson).get("");
- System.out.println(jsonAsArrayList);
- }
- }
Add Comment
Please, Sign In to add comment