Skip to content
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

Merged
merged 8 commits into from Jun 24, 2021
Merged

Add "func" Decoder #257

merged 8 commits into from Jun 24, 2021

Conversation

Kiraub
Copy link
Contributor

@Kiraub Kiraub commented Jun 23, 2021

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

Copy link
Owner

@goccy goccy left a 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 .

helper_test.go Outdated Show resolved Hide resolved
}
src := s.buf[start:s.cursor]
if len(src) > 0 {
switch src[0] {
Copy link
Owner

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).

Copy link
Contributor Author

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-commenter
Copy link

codecov-commenter commented Jun 23, 2021

Codecov Report

Merging #257 (9d9e5cd) into master (f7eceb1) will decrease coverage by 0.39%.
The diff coverage is 18.00%.

@@            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     

@goccy
Copy link
Owner

goccy commented Jun 24, 2021

LGTM ! Thank you for your contribution !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants