-
-
Notifications
You must be signed in to change notification settings - Fork 166
Add "func" Decoder #257
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
Add "func" Decoder #257
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for your great PR !
I think it's very good to process with funcDecoder
.
I made some comments .
} | ||
src := s.buf[start:s.cursor] | ||
if len(src) > 0 { | ||
switch src[0] { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems better to be able to make an error even if the values are different (e.g. true
or false
or other characters).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've added the cases for true
and false
.
The stdjson returns an error invalid character 'a' looking for beginning of value
. This could be added to internal/errors/errors.go
for other unexpected characters.
Codecov Report
@@ Coverage Diff @@
## master #257 +/- ##
==========================================
- Coverage 81.37% 80.97% -0.40%
==========================================
Files 46 47 +1
Lines 14663 14763 +100
==========================================
+ Hits 11932 11955 +23
- Misses 2177 2255 +78
+ Partials 554 553 -1 |
LGTM ! Thank you for your contribution ! |
Fix for #255
The basic Decoder for values of type "func" accepts "null" as a valid value.
Omitting the field is also valid.
Both will result in the field having the value
nil
.Any other value will result in an UnmarshalTypeError