Jli | 2022-10-24 02:59:01 UTC | #1
Hi, I was expecting a json fomatted response data from the Analytics-apis below,but the fomat of the response data I got from my app was not json fomatted . Analytics APIs (genesys.cloud) →/api/v2/analytics/flows/aggregates/query
Also the format of the result data I got through Developer tools was different from what I got from my java application using Java SDK.
①Can you give me some advices on how to get the response data in the same fomat (json fomat) from java application as Developer tools gets?
②If ①is not possible(unachievable), do you hava any solutions or advices on how to parse the response data I got form my app into java objects,thank you !
(What I want to do is to set every field of the resopnse data into java classes. If the format of response data is json fomatted data, I can parse the data easilly into java classes using 「Jackson」library. But I fact is the response data got form my app was not json formatted. )
■Response data form Developer tools( an excerpt of the whole response) { "results": [ { "group": { "mediaType": "voice" }, "data": [ { "interval": "2022-03-14T04:00:00.000Z/2022-03-14T04:30:00.000Z", "metrics": [ { "metric": "nFlow", "stats": { "count": 4 } ...... ■Response data form java Application( an excerpt of the whole response) class FlowAggregateQueryResponse { results: [class FlowAggregateDataContainer { group: {mediaType=voice} data: [class StatisticalResponse { interval: 2022-10-06T02:30:00.000Z/2022-10-06T03:00:00.000Z metrics: [class AggregateMetricData { metric: nFlow qualifier: null stats: class StatisticalSummary { max: null min: null count: 2 countNegative: null countPositive: null sum: null current: null ratio: null numerator: null denominator: null target: null } ...... Thank you !
anon14299330 | 2022-10-24 09:20:27 UTC | #2
Hi,
To get the response formatted as json, you can use Jacksons ObjectMapper like so:
// Query for flow aggregates
FlowAggregateQueryResponse result = apiInstance.postAnalyticsFlowsAggregatesQuery(body);
ObjectMapper objectMapper = new ObjectMapper();
String jsonStr = objectMapper.writerWithDefaultPrettyPrinter().writeValueAsString(result.getResults());
System.out.println(jsonStr);
Thanks,
Mike
Jli | 2022-10-25 10:31:26 UTC | #3
Thank you for your advice! This is very helpful.
system | 2022-11-25 10:31:41 UTC | #4
This topic was automatically closed 31 days after the last reply. New replies are no longer allowed.
This post was migrated from the old Developer Forum.
ref: 16846