Response data parsing (the reslut of Analytics-apis)

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 !

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

Thank you for your advice!
This is very helpful.

This topic was automatically closed 31 days after the last reply. New replies are no longer allowed.