-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
🐛 [Bug]: Unclear "json: invalid use of ,string struct tag, trying to unmarshal unquoted value into uint64" #3025
Comments
Thanks for opening your first issue here! 🎉 Be sure to follow the issue template! If you need help or want to chat with us, join us on Discord https://gofiber.io/discord |
@kokizzu It doesn't sound like a bug because your JSON is wrong. I've tested using package main
import (
"encoding/json"
"fmt"
)
type Foo struct {
A uint64 `json:"a,string"`
B int64 `json:"b,string"`
C uint64 `json:"c"`
D int64 `json:"d"`
}
func main() {
var f Foo
// json: invalid use of ,string struct tag, trying to unmarshal unquoted value into uint64 {0 123 0 123}
err := json.Unmarshal([]byte(`{"a":123,"b":"123","c":"123","d":123}`), &f)
fmt.Println(err, f)
// success
err = json.Unmarshal([]byte(`{"a":"123","b":"123","c":123,"d":123}`), &f)
fmt.Println(err, f)
} Try using this CURL: |
yes, what i'm asking is clearer error message |
I mean if i have 24 fields, i didn't know which one is the issue, this one is just minimal example of 4 fields, i know for sure what's wrong for this one, but if there's 24 fields, that's pain |
@kokizzu We use the encoder or decoder of the standard packet internally |
apparently this related |
@kokizzu Of course, but it isn't a bug from Fiber. I've been trying to understand where this error message is concatenated, but I haven't found it yet. |
Hey @kokizzu, I apologize if my communication hasn't been very clear. I think I understood your suggestion. If you need help contributing to the Golang main repository, just let me know. |
no problem, end up using json5 decoder with number-string patch instead |
Bug Description
Currently it doesn't show which struct have that are uint64 that cannot be parsed by BodyParser
How to Reproduce
Steps to reproduce the behavior:
json:"fieldNameXX,string"
field, an endpoint, call BodyParser with payload unquoted an quotedExpected Behavior
It would show which field failed to be parsed
for quality of life it should be more permissive between quoted and unquoted number
Fiber Version
v2.52.4
Code Snippet (optional)
Checklist:
The text was updated successfully, but these errors were encountered: