Simplified json usage
This commit is contained in:
parent
235679a913
commit
ec5871289b
@ -1,12 +0,0 @@
|
|||||||
package storage
|
|
||||||
|
|
||||||
import (
|
|
||||||
"encoding/json"
|
|
||||||
"io"
|
|
||||||
)
|
|
||||||
|
|
||||||
var NewDecoder = func(r io.Reader) Decoder { return json.NewDecoder(r) }
|
|
||||||
|
|
||||||
type Decoder interface {
|
|
||||||
Decode(any) error
|
|
||||||
}
|
|
@ -1,12 +0,0 @@
|
|||||||
package storage
|
|
||||||
|
|
||||||
import (
|
|
||||||
"encoding/json"
|
|
||||||
"io"
|
|
||||||
)
|
|
||||||
|
|
||||||
var NewEncoder = func(w io.Writer) Encoder { return json.NewEncoder(w) }
|
|
||||||
|
|
||||||
type Encoder interface {
|
|
||||||
Encode(any) error
|
|
||||||
}
|
|
@ -173,7 +173,7 @@ func (fs *File[T]) writeTo(writer io.Writer) error {
|
|||||||
return records[i].key < records[j].key
|
return records[i].key < records[j].key
|
||||||
})
|
})
|
||||||
|
|
||||||
encoder := NewEncoder(writer)
|
encoder := json.NewEncoder(writer)
|
||||||
|
|
||||||
for _, record := range records {
|
for _, record := range records {
|
||||||
_, err := stringWriter.WriteString(record.key)
|
_, err := stringWriter.WriteString(record.key)
|
||||||
|
Loading…
Reference in New Issue
Block a user