-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
JSONText broken #266
Comments
Ok, got it. // MarshalJSON returns the *j as the JSON encoding of j.
func (j *JSONText) MarshalJSON() ([]byte, error) {
if len(*j) == 0 {
*j = _EMPTY_JSON
}
return *j, nil
} should be // MarshalJSON returns the j as the JSON encoding of j.
func (j JSONText) MarshalJSON() ([]byte, error) {
if len(j) == 0 {
j = _EMPTY_JSON
}
return j, nil
} Otherwise the func is never called. |
gravis
pushed a commit
to gravis/sqlx
that referenced
this issue
Dec 6, 2016
closes jmoiron#266 When using `JSONText` in a struct, the field is not a pointer, and therefore the func is never called, leading to unexpected results. This change works with `*JSONText`, as well as `JSONText`. Thanks.
jmoiron
added a commit
that referenced
this issue
Dec 7, 2016
I don't see a reason to have that mutation in the first place. f9b4c7a passed tests, can you make sure it works for you? |
It works! |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Until recently,
JSONText
was acting like a string, and since 6708aed, we have a lot of issues with this type.See the following code:
before the commit, it was returning
{"Z":[]}
as expected, and after{"Z":"W10="}
The text was updated successfully, but these errors were encountered: