This commit is contained in:
Bruce Marriner 2016-06-04 15:52:39 -05:00
parent db0acce1d0
commit 348dc1e55f
2 changed files with 2 additions and 1 deletions

View File

@ -123,6 +123,7 @@ func (f ID) Step() int64 {
return int64(f) & 0x0000000000000FFF
}
// MarshalJSON returns a json byte array string of the snowflake ID.
func (f ID) MarshalJSON() ([]byte, error) {
return []byte(`"` + f.String() + `"`), nil
}

View File

@ -24,7 +24,7 @@ func BenchmarkUnmarshal(b *testing.B) {
b.ResetTimer()
for n := 0; n < b.N; n++ {
id2.UnmarshalJSON(id.Bytes())
_ = id2.UnmarshalJSON(id.Bytes())
}
}