Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6891099
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T06:22:00+00:00 2026-05-27T06:22:00+00:00

I have a JSON feed that I’m parsing. Here’s the following code samples: JSON

  • 0

I have a JSON feed that I’m parsing. Here’s the following code samples:

JSON

[
   {
      "global_event":{
         "ending_at":"2011-11-07T02:00:00Z",
         "short_url":"http://bit.ly/reAhRw",
         "created_at":"2011-10-04T14:25:41Z",
         "event_responses":[

         ],
         "addresses":{
            "location":{
               "city":"blah",
               "latitude":30.205288,
               "zipcode":"343434",
               "street":"blah",
               "longitude":-95.475289,
               "state":"TX"
            }
         },
         "body":"blahblahblah",
         "euid":"2f489d0c82d167f1c16aba5d3b4c29ade6f1d52a",
         "title":"Fusion",
         "updated_at":"2011-10-04T14:26:57Z",
         "event_roles":[

         ],
         "user":{
            "long_name":"Fusion Single",
            "nickname":""
         },
         "event_items":[

         ],
         "starting_at":"2011-11-07T00:00:00Z"
      }
   }
]

Controller

def events
    @json = ActiveSupport::JSON.decode(open('jsonfeed').read)
end

View

<ul class="events">
    <% @json.each do |event| %>
        <% event.each do |e, d| %>
            <li>
                <h4><%= d['starting_at'].to_date.strftime('%A') %></h4>
                    <small><%= d['starting_at'].to_date.strftime('%b %d') %></small>
                    <p>
                        <%= link_to d['title'], d['short_url'] %> <span style="font-size: 12px; padding: 0 10px; font-weight: bold;">|</span> 
                        <%= d['starting_at'].to_date.strftime('%I:%M %p') %>
                    </p>
            </li>
        <% end %>
    <% end %>
</ul>

Finally, with all of this in place, it is working perfectly. Here’s what my output looks like: enter image description here

So, finally my question: As you can see in the screenshot, both of the items being printed onto the screen have the same date (January 14). What I would like to do is have both of those combined. My final output would therefore have ‘Saturday’ with the two events listed underneath it. Thanks for the help!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T06:22:01+00:00Added an answer on May 27, 2026 at 6:22 am

    The following code should help you to group your events by date:

    Controller

    def events
        @json = ActiveSupport::JSON.decode(open('jsonfeed').read).group_by {|e| e["global_event"]["starting_at"].to_date.strftime('%Y-%m-%d') }
    end
    

    The resulting data structure:

    {"2011-11-07"=>
      [{"global_event"=>
         {
          "ending_at"=>"2011-11-07T02:00:00Z",
          "short_url"=>"http://bit.ly/reAhRw",
          "created_at"=>"2011-10-04T14:25:41Z",
          "event_responses"=>[],
          "addresses"=>
           {"location"=>
             {"city"=>"blah",
              "latitude"=>30.205288,
              "zipcode"=>"343434",
              "street"=>"blah",
              "longitude"=>-95.475289,
              "state"=>"TX"
             }
           },
          "body"=>"blahblahblah",
          "euid"=>"2f489d0c82d167f1c16aba5d3b4c29ade6f1d52a",
          "title"=>"Fusion",
          "updated_at"=>"2011-10-04T14:26:57Z",
          "event_roles"=>[],
          "user"=>{"long_name"=>"Fusion Single", "nickname"=>""},
          "event_items"=>[],
          "starting_at"=>"2011-11-07T00:00:00Z"
         }
      }]
    }
    

    View

    <ul class="events">
        <% @json.each do |date, events| %>
            <li>
                <h4><%= date.to_date.strftime('%A') %></h4>
                <small><%= date.to_date.strftime('%b %d') %></small>
                    <% events.each do |e| %>
                        <p>
                            <%= link_to e['global_event']['title'], e['global_event']['short_url'] %> <span style="font-size: 12px; padding: 0 10px; font-weight: bold;">|</span> 
                            <%= e['global_event']['starting_at'].to_date.strftime('%I:%M %p') %>
                        </p>
                    <% end %>
            </li>
        <% end %>
    </ul>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following JSON content that I'm pulling from a service feed: [
I have a series of Moose objects that I'm looking to feed to JSON::XS
I have a json feed from zoho : here , you can acces the
So I have an app that downloads and parses a JSON feed with some
I have a web service class that successfully pulls my JSON from a feed
I have a JSON feed that drupal spits out time in this format: 2010-12-16T04:41:35Z
I have a mapView that has annotation added through JSON (feed is stored in
I have a function that retrieves some images from a JSON feed using NSURLConnection.
I have created a jQuery plugin that grabs a JSON feed (in this case
I have a JSON feed (which I don't directly control, I have to ask

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.