Properly render JSON
This commit is contained in:
parent
8e04491386
commit
6354a824f9
|
@ -1,10 +1,11 @@
|
||||||
package cmd
|
package cmd
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"net/http"
|
|
||||||
|
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
|
"log"
|
||||||
|
"net/http"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
|
@ -20,12 +21,12 @@ func server() {
|
||||||
|
|
||||||
func returnWeather(c *gin.Context) {
|
func returnWeather(c *gin.Context) {
|
||||||
jsonData := getJSON()
|
jsonData := getJSON()
|
||||||
c.IndentedJSON(http.StatusOK, jsonData)
|
textBytes := []byte(jsonData)
|
||||||
//textBytes := []byte(jsonData)
|
aemetRequest := root{}
|
||||||
// aemetRequest := root{}
|
err := json.Unmarshal(textBytes, &aemetRequest)
|
||||||
// err := json.Unmarshal(textBytes, &aemetRequest)
|
if err != nil {
|
||||||
// if err != nil {
|
log.Fatalf("Error occurred unmarshalling data: %v\n", err)
|
||||||
// log.Fatalf("Error occurred unmarshalling data: %v\n", err)
|
}
|
||||||
// }
|
|
||||||
|
|
||||||
|
c.IndentedJSON(http.StatusOK, aemetRequest)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue