JSON::Feed - Syndication with JSON.



    JSON::Feed->from_string( $json_text );


    # Initialize, with some content.
    my $feed = JSON::Feed->new(
        title    => "An example of JSON feed",
        feed_url => "",
        items    => [
                id => 42,
                url => '',
                summary => 'An item with some summary',
                date_published: "2019-03-06T09:24:03+09:00"
                id => 623,
                url => '',
                summary => 'An item with some summary',
                date_published: "2019-03-07T06:22:51+09:00"

    # Mutate
    $feed->set( description => 'Some description here.' );
        id => 789,
        title => "Another URL-less item here",
        summary => "Another item here. Lorem ipsum yatta yatta yatta.",

    # Output
    print $fh $feed->to_string;


JSON Feed is a simple format for website syndication with JSON, instead of XML.

This module implements minimal amout of API for parsing and/or generating such feeds. The users of this module should glance over the jsonfeed spec in order to correctly generate a JSON::Feed.

Here's a short but yet comprehensive Type mapping between jsonfeed spec and perl.

    | jsonfeed | perl                       |
    | object   | HashRef                    |
    | boolean  | JSON::true, or JSON::false |
    | string   | Str                        |
    | array    | ArrayRef                   |


set( $attr, $value )

The $attr here must be a name from one top-level attribute from v1 spec.

The passed $value thus must be the corresponding value.

Most of the values from spec are strings and that maps to a perl scalar veraible. The term `object` in the spec is mapped to a perl HashRef.

Be aware that the spec allows feed extensions by prefixng attributes with underscore character. Thus, all strings begin with '_' are valid. Whatever those extented attributes mapped to are left as-is.

get( $attr )

Retrieve the value of the given top-level varible.

add_item( JSONFeedItem $item )

Apend the given $item to the items attribute. The type of input $item is described in the "Items" section of the spec.


Stringify this JSON Feed. At this moment, the feed structure is checked and if it is invalid, an exception is thrown.

from_string( $json_text )

Take a reference to a string that is assumed to be a valid json feed and produce an object from it. Exception will be thrown if the input is not a valid JSON feed.

This method is supposed to be consume the output of to_string method without throwing exceptions.


JSON Feed spec v1


Kang-min Liu <>