I am new to Grafana and Spring Boot. I am trying to create a Spring Boot application, and use Grafana SimpleJSON plugin to get data from my Spring Boot APIs and create graphs. (Just for reference, not too relevant to my question - I'm following instructions here https://grafana.com/grafana/plugins/grafana-simple-json-datasource/)
Right now I am just hard-coding data into my Spring Boot App, but am stuck on getting the correct JSON format I need.
What I want:
[
{
"columns":[
{"text":"Time","type":"time"},
{"text":"Country","type":"string"},
{"text":"Number","type":"number"}
],
"rows":[
[1234567,"SE",123],
[1234567,"DE",231],
[1234567,"US",321]
],
"type":"table"
}
]
What is the best way to implement this?
So far, I've tried to create a custom class, and also tried to just use Map (How to return JSON response in Springboot?). But encountered the same issue in both methods - data in "rows" have different types (e.g. [1234567,"SE",123]). How can I go by this?
@PostMapping("/query")
public ??? getData() {
...
}
Thanks!