fix: ignore empty json strings for locale
This commit is contained in:
parent
759105530d
commit
e59961cb2a
2 changed files with 37 additions and 9 deletions
|
@ -82,6 +82,9 @@ func (l *Locale) MarshalJSON() ([]byte, error) {
|
|||
// to an empty value (language "und") and no error will be returned.
|
||||
// This state can be checked with the `l.Tag().IsRoot()` method.
|
||||
func (l *Locale) UnmarshalJSON(data []byte) error {
|
||||
if len(data) == 0 || string(data) == "\"\"" {
|
||||
return nil
|
||||
}
|
||||
err := json.Unmarshal(data, &l.tag)
|
||||
if err == nil {
|
||||
return nil
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue