SDK query used: Classic environment v1 | Dynatrace Developer
I have an api query that returns the result as a json payload with a field for columns and values (records) as arrays:
import { rumUserSessionsClient } from "@dynatrace-sdk/client-classic-environment-v1";
export default async function () {
const response = await rumUserSessionsClient.getUsqlResultAsTable({
query: "SELECT DISTINCT city, country FROM usersession",
startTimestamp: 0 ,
endTimestamp: 0,
pageOffset: 0
});
return response;
}
Im attempting to get this into JSON. However, the response is not valid JSON but rather arrays of arrays for the records and an array for columnNames:
Here is the documentation for the sdk query result type/promise: Classic environment v1 | Dynatrace Developer
Example response :
The fields are in the columnNames array and the records are in the values array of arrays:
| columnNames | Array<string> | A list of columns in the result table. |
| values | Array<Array<any>> | A list of data rows.Each array element represents a row in the result table.The size of each data row and the order of the elements correspond to the columnNames content. |
Example response :
{
"extrapolationLevel": 1,
"columnNames": [
"city",
"country"
],
"values": [
[
"Burlington",
"Canada"
],
[
"Cary",
"United States"
],
[
"Johannesburg",
"South Africa"
],
[
"Los Angeles",
"United States"
],
[
"Manchester",
"United Kingdom"
],
[
"Northampton",
"United Kingdom"
],
[
"Stoke-on-Trent",
"United Kingdom"
]
]
}
How can I transform this result into a usable JSON table that can be used in visualisations?
Even record list does not yeild the intended result:



