-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.
Already on GitHub? Sign in to your account
馃 always get empty JSON response #164
Comments
Thanks for opening your first issue here! 馃帀 Be sure to follow the issue template! |
Make sure that your struct keys are exported using capitalization so the JSON parser can access it. package main
import (
"github.com/gofiber/fiber"
)
func main() {
app := fiber.New()
type status struct {
Code int32
Message string
}
// {"Code":200,"Message":"Hello, World"}
app.Get("/", func(c *fiber.Ctx) {
c.JSON(status{200, "Hello, World"})
})
type statusLwr struct {
Code int32 `json:"code"`
Message string `json:"message"`
}
// {"code":200,"message":"Hello, World"}
app.Get("/", func(c *fiber.Ctx) {
c.JSON(statusLwr{200, "Hello, World"})
})
// {"code":200,"message":"Hello, World"}
app.Get("/", func(c *fiber.Ctx) {
c.JSON(fiber.Map{"code": 200, "message": "Hello, World"})
})
app.Listen(3000)
} |
I hate to ask this, but I am really new to golang. Fiber is my first framework to try out. How to get v2.0.0? I use:
the go mod report:
I also tried the I read in the blog, the pre-release version must contain a hyphen ? |
It worked after I change to Uppercase. Thank you for the reply. |
@washanhanzi, the package main
import (
"fmt"
"github.com/gofiber/fiber"
)
func main() {
fmt.Println(fiber.Version)
} If this doesn't work, delete the fiber folder |
In the T_T Also got Never see |
I found the |
I'm closing the issue. I will try to figure out the go mod. T_T Thank you for the great framework. |
Question description
{}
from JSON response.c.JSON()
method.{}
. withJSONP
method, the response is alwayscallback{}
.Code snippet (optional)
The text was updated successfully, but these errors were encountered: