Simplified json usage

This commit is contained in:
Eduard Urbach 2023-07-17 19:52:26 +02:00
parent 235679a913
commit ec5871289b
Signed by: akyoto
GPG Key ID: C874F672B1AF20C0
3 changed files with 1 additions and 25 deletions

View File

@ -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
}

View File

@ -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
}

View File

@ -173,7 +173,7 @@ func (fs *File[T]) writeTo(writer io.Writer) error {
return records[i].key < records[j].key
})
encoder := NewEncoder(writer)
encoder := json.NewEncoder(writer)
for _, record := range records {
_, err := stringWriter.WriteString(record.key)