Return error on MarshalJSON of status Undefined

Previously "undefined" was returned as a value. While this is a
valid JavaScript value, it is not valid JSON.
This commit is contained in:
Jack Christensen 2017-08-12 16:40:18 -05:00
parent a5f166bd21
commit 10fa3a6497
4 changed files with 4 additions and 4 deletions

View File

@ -202,7 +202,7 @@ func (src *Int2) MarshalJSON() ([]byte, error) {
case Null: case Null:
return []byte("null"), nil return []byte("null"), nil
case Undefined: case Undefined:
return []byte("undefined"), nil return nil, errUndefined
} }
return nil, errBadStatus return nil, errBadStatus

View File

@ -193,7 +193,7 @@ func (src *Int4) MarshalJSON() ([]byte, error) {
case Null: case Null:
return []byte("null"), nil return []byte("null"), nil
case Undefined: case Undefined:
return []byte("undefined"), nil return nil, errUndefined
} }
return nil, errBadStatus return nil, errBadStatus

View File

@ -179,7 +179,7 @@ func (src *Int8) MarshalJSON() ([]byte, error) {
case Null: case Null:
return []byte("null"), nil return []byte("null"), nil
case Undefined: case Undefined:
return []byte("undefined"), nil return nil, errUndefined
} }
return nil, errBadStatus return nil, errBadStatus

View File

@ -144,7 +144,7 @@ func (src *Text) MarshalJSON() ([]byte, error) {
case Null: case Null:
return []byte("null"), nil return []byte("null"), nil
case Undefined: case Undefined:
return []byte("undefined"), nil return nil, errUndefined
} }
return nil, errBadStatus return nil, errBadStatus