Erstes Commit

This commit is contained in:
2026-07-12 02:49:54 +02:00
commit 6dd456ca4a
15 changed files with 920 additions and 0 deletions

View File

@@ -0,0 +1,27 @@
package formatter
import (
"encoding/json"
"io"
"royalroadupdates/internal/royalroad"
)
// jsonEntry is the JSON output shape.
type jsonEntry struct {
Name string `json:"name"`
Date string `json:"date"`
}
// PrintJSON writes stories as JSON to w.
func PrintJSON(w io.Writer, stories []royalroad.Story) error {
entries := make([]jsonEntry, 0, len(stories))
for _, s := range stories {
entries = append(entries, jsonEntry{
Name: s.Name,
Date: s.DateModified.UTC().Format("2006-01-02T15:04:05Z"),
})
}
enc := json.NewEncoder(w)
return enc.Encode(entries)
}