mirror of
https://github.com/miniflux/v2.git
synced 2024-08-19 02:43:24 +02:00
23 lines
605 B
Go
23 lines
605 B
Go
// SPDX-FileCopyrightText: Copyright The Miniflux Authors. All rights reserved.
|
|
// SPDX-License-Identifier: Apache-2.0
|
|
|
|
package json // import "miniflux.app/v2/internal/reader/json"
|
|
|
|
import (
|
|
"encoding/json"
|
|
"fmt"
|
|
"io"
|
|
|
|
"miniflux.app/v2/internal/model"
|
|
)
|
|
|
|
// Parse returns a normalized feed struct from a JSON feed.
|
|
func Parse(baseURL string, data io.Reader) (*model.Feed, error) {
|
|
jsonFeed := new(JSONFeed)
|
|
if err := json.NewDecoder(data).Decode(&jsonFeed); err != nil {
|
|
return nil, fmt.Errorf("json: unable to parse feed: %w", err)
|
|
}
|
|
|
|
return NewJSONAdapter(jsonFeed).BuildFeed(baseURL), nil
|
|
}
|