关于java:通过java的小程序来获取uri中的json数据

31次阅读

共计 3349 个字符,预计需要花费 9 分钟才能阅读完成。

public class TestJson {Client client = ClientBuilder.newClient();

@Test
    public void test() {
        String uri = "https://idaas-admin.aoya-hk.com/gateway/api/v1/tn-c6f4d13e7de14b36ad8a3620e469fae9/connections/cn-4d9a5e4f017d470c90074756544d5b22/infos?status=CONNECTED_ERROR&status=UNCONNECTED&status=PRE_CONNECTED&operation=CREATE&page=0&size=10000";
        String cookie = "refresh_token=eyJraWQiOiI4YzVjNWE5N2M5Mzg2YTgxYTY0YjdlZDU0YWY0MGM4NTVhODY5YzM2IiwiYWxnIjoiUlMyNTYifQ.eyJzdWIiOiJrZWtld2FuZ0B5dWZ1aWQuY29tIiwiYWNjb3VudF90eXBlIjoidXNlckFjY291bnQiLCJpc3MiOiJhZG1pbiIsInJldm9jYWJsZSI6dHJ1ZSwiYXVkIjoiYWRtaW4iLCJ1c2VyX2lkIjoidXMtYTM1ZDBlODQzNTFmNDdlZDgyYzA5YmY0ZWNlNTYxNGQiLCJwZXJtaXNzaW9ucyI6WyJhZG1pbiJdLCJ0bnRfaWQiOiJ0bi1jNmY0ZDEzZTdkZTE0YjM2YWQ4YTM2MjBlNDY5ZmFlOSIsInNjb3BlIjoiYWRtaW4iLCJleHAiOjE2MzQzMTQ0OTksImlhdCI6MTYzNDI3ODQ5OSwianRpIjoiODMxYTRiZTUtZmU1MC00M2ZiLWE4YzQtZGFjZTMwNjJlOGY5In0.Ao03t9kFyArUS5NnY2qEDHadB7Kg-pdZr0noKI2vpQr_VndMwkUwwhc-XjlCiIx4AmkrLfLfRh0kyDFNfU9R3dl4wFCO9Fq3FnLoaKIx6udVLRDCYQyCMam_XEDN9wnPwXP0kFb1lcRYY5UTWVnZVdsaJXKdXTGBQUtbbe9vohxfydVnZCUWB_YcpTPLGH7KbtZILXTaL8GsGrzlPQOWuGjAc3k2dfR4pNMS_JUohIfBb8t5OsS16UlOfW8sdiysyDULgDV2rUS4EOn97NacxUku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JhY2NvdW50X3R5cGUiOiJ1c2VyQWNjb3VudCIsInVzZXJfaWQiOiJ1cy1hMzVkMGU4NDM1MWY0N2VkODJjMDliZjRlY2U1NjE0ZCIsInBlcm1pc3Npb25zIjpbImFkbWluIl0sInRudF9pZCI6InRuLWM2ZjRkMTNlN2RlMTRiMzZhZDhhMzYyMGU0NjlmYWU5Iiwic2NvcGUiOiJhZG1pbiIsImlzcyI6ImFkbWluIiwiZXhwIjoxNjM0MjgzNDcxLCJpYXQiOjE2MzQyODMxNzEsImp0aSI6IjM2NzQ4NTQ1LTgyZGYtNDJjOC1hYmRhLWZhZDIzZTIzNTFkZCJ9.FigPtZM-w3HDALrPlDKEKpCJG4637NXkmzFbJnhOx-OwB7GB0LQZjzx1HZX-DUNMKGusigSmL4cJOYzk6fVOYH6YyFKNZj6Z8xNjNgNFqtgb4tT7CzSS6JXYdC-A-jj9OUpysFCuLlNM20f-0RHvxehFoA5SC-F5_Bjyd62aTbp-_ggqCl88OPNQQleOtPDK7S2vqJloyg6r_5U2Umi9jKJVKhAqadp3TEu-yTHMY3Ov0YajhfK2FyNzHJS2Lw2bG8zMQMiv7zkVsuZGm-G0wyRNBTcga33yuh8nYF6A35qS4nPKwBMw3Xw53154qBORPcc-IRoIOJdXlHRoPTvnRA";
        Response response = client.target(uri)
                .request(MediaType.APPLICATION_JSON)
                .header("cookie",cookie)
                .get();
        Map<String, Map> respMap = response.readEntity(Map.class);
        List<Map> list = (List)respMap.get("data");
        for(Map map:list){Map datamap = (Map)((Map)map.get("sourceData")).get("data");
            System.out.println(datamap.get("userID")+","+
                    datamap.get("phoneNum")+","+
                    datamap.get("username")+","+
                    datamap.get("primaryMail"));
        }
        System.out.println();}
}

正文完
 0