summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDmitry Ilvokhin <d@ilvokhin.com>2025-03-15 20:44:38 +0000
committerDmitry Ilvokhin <d@ilvokhin.com>2025-03-15 20:44:38 +0000
commitbbf5d9d99aa6131dccada8908b770ac10f52be59 (patch)
tree9497ef07375a0cefc7a5814df5f1e2078cc8e4c9
parent5e1371457efa7f36913413eb4bc2cd045123f4de (diff)
downloadflatbot-bbf5d9d99aa6131dccada8908b770ac10f52be59.tar.gz
flatbot-bbf5d9d99aa6131dccada8908b770ac10f52be59.tar.bz2
flatbot-bbf5d9d99aa6131dccada8908b770ac10f52be59.zip
Annotate `flat` fileds for JSON
-rw-r--r--flat.go4
-rw-r--r--sent_test.go6
2 files changed, 5 insertions, 5 deletions
diff --git a/flat.go b/flat.go
index a655856..5f22009 100644
--- a/flat.go
+++ b/flat.go
@@ -6,8 +6,8 @@ import (
)
type flat struct {
- ID int
- Price string
+ ID int `json:"id"`
+ Price string `json:"price"`
}
func (f *flat) URL() string {
diff --git a/sent_test.go b/sent_test.go
index 5232832..f8a72f0 100644
--- a/sent_test.go
+++ b/sent_test.go
@@ -22,7 +22,7 @@ func TestReadSentNew(t *testing.T) {
func TestReadSent(t *testing.T) {
tmp := t.TempDir()
filename := filepath.Join(tmp, "sent.json")
- data := []byte(`[{"ID":156522206,"Price":"£2,500"}]`)
+ data := []byte(`[{"id":156522206,"price":"£2,500"}]`)
os.WriteFile(filename, data, 0644)
got, err := readSent(filename)
@@ -105,7 +105,7 @@ func TestWriteSentNew(t *testing.T) {
if err != nil {
t.Fatal(err)
}
- want := []byte(`[{"ID":156522206,"Price":"£2,500"}]`)
+ want := []byte(`[{"id":156522206,"price":"£2,500"}]`)
if !reflect.DeepEqual(got, want) {
t.Errorf("writeSent failed: got: %v, want: %v", got, want)
}
@@ -128,7 +128,7 @@ func TestWriteSentOverride(t *testing.T) {
if err != nil {
t.Fatal(err)
}
- want := []byte(`[{"ID":156522206,"Price":"£2,500"}]`)
+ want := []byte(`[{"id":156522206,"price":"£2,500"}]`)
if !reflect.DeepEqual(got, want) {
t.Errorf("writeSent failed: got: %v, want: %v", got, want)
}