Documentation
¶
Overview ¶
Package null defines Null variants of the primitive types. It is supposed that users may define their own types to satisfy their needs. The purpose of these types is to give the basic idea on how to define custom types.
The advantage of these types over original database/sql Null* types is that (un)marshaling to JSON works as expected. So, instead of:
{ "title": { "Valid": true, "String": "Octopus" }, "description": { "Valid": false, "String": "" } }
it is now marshaled like this:
{ "title": "Octopus", "description": null }
Other kinds of marshaling (e.g. XML) are not implemented yet. Anyway, it is not possible (nor desired) to cover everyone's needs for Null* types, so it is recommended to define own types.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Bool ¶
Bool is a type that can be null or a bool.
func (*Bool) MarshalJSON ¶
MarshalJSON correctly serializes a Bool to JSON.
func (*Bool) UnmarshalJSON ¶
UnmarshalJSON correctly deserializes a Bool from JSON.
type Float64 ¶
type Float64 struct {
sql.NullFloat64
}
Float64 is a type that can be null or a float64.
func (*Float64) MarshalJSON ¶
MarshalJSON correctly serializes a Float64 to JSON.
func (*Float64) UnmarshalJSON ¶
UnmarshalJSON correctly deserializes a Float64 from JSON.
type Int64 ¶
Int64 is a type that can be null or an int.
func (*Int64) MarshalJSON ¶
MarshalJSON correctly serializes a Int64 to JSON.
func (*Int64) UnmarshalJSON ¶
UnmarshalJSON correctly deserializes a Int64 from JSON.
type String ¶
type String struct {
sql.NullString
}
String is a type that can be null or a string.
func (*String) MarshalJSON ¶
MarshalJSON correctly serializes a String to JSON.
func (*String) UnmarshalJSON ¶
UnmarshalJSON correctly deserializes a String from JSON.