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 6221463
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T08:08:16+00:00 2026-05-24T08:08:16+00:00

I need to take an array of data called @users and turn it into

  • 0

I need to take an array of data called @users and turn it into a json response with the correct formatting.

The @users array has a bunch of attributes. I only need id and screen_name, but I need the formatting to look like this:

[
    {"id":"856","screen_name":"joerogan"},
    {"id":"1035","screen_name":"redban"},
    {"id":"1245","screen_name":"madflavor"}
    ...
]

def user_json_list
...

results = @users   # ?

 respond_to do |format|
      format.html
      format.json { render :json => results }
 end
end

The @users array looks like this:

[{
    "profile_sidebar_fill_color":"C0DFEC",
    "protected":false,
    "is_translator":false,
    "default_profile":false,
    "lang":"en",
    "profile_background_tile":false,
    "profile_image_url":"http://a3.twimg.com/profile_images/1443034111/new_avatar_normal.jpg",
    "name":"Joe Rogan",
    "follow_request_sent":false,
    "verified":true,
    "utc_offset":-25200,
    "profile_link_color":"0084B4",
    "followers_count":416343,
    "screen_name":"joerogan",
    "profile_sidebar_border_color":"a8c7f7",
    "location":"","contributors_enabled":false,
    "time_zone":"Mountain Time (US & Canada)",
    "status":
    {
        "favorited":false,
        "in_reply_to_status_id_str":null,
        "place":null,
        "in_reply_to_screen_name":null,
        "in_reply_to_user_id_str":null,
        "contributors":null,"geo":null,
        "retweeted":false,
        "truncated":false,
        "coordinates":null,
        "text":"The Joe Rogan Daily is out! http://bit.ly/bgRzbI \u25b8 Top stories today via @bryanbrinkman @madmanwoo",
        "in_reply_to_user_id":null,
        "retweet_count":0,
        "in_reply_to_status_id":null,
        "id_str":"99032523769782272",
        "source":"<a href=\"http://paper.li\" rel=\"nofollow\">Paper.li</a>",
        "created_at":"Thu Aug 04 08:22:48 +0000 2011",
        "possibly_sensitive":false,
        "id":99032523769782272
    },
    "show_all_inline_media":false,
    "listed_count":9675,
    "following":true,
    "geo_enabled":false,
    "profile_use_background_image":true,
    "profile_background_image_url_https":"https://si0.twimg.com/profile_background_images/293713769/back.jpg",
    "url":"http://www.joerogan.net",
    "description":"Stand up comic/mixed martial arts fanatic/psychedelic adventurer/occasional tv whore\r\n\r\nSayNow number: 818-237-4245",
    "profile_background_color":"022330",
    "profile_image_url_https":"https://si0.twimg.com/profile_images/1443034111/new_avatar_normal.jpg",
    "id_str":"18208354",
    "profile_background_image_url":"http://a0.twimg.com/profile_background_images/293713769/back.jpg",
    "created_at":"Thu Dec 18 04:01:47 +0000 2008",
    "statuses_count":7464,
    "notifications":false,
    "friends_count":982,"id":18208354,
    "default_profile_image":false,
    "favourites_count":88,"profile_text_color":"333333"
},

{
    "listed_count":517,
    "profile_background_image_url_https":"https://si0.twimg.com/profile_background_images/188153775/redbak.jpg",
    "profile_sidebar_fill_color":"C0DFEC",
    "protected":false,
    "lang":"en",
    "profile_background_tile":true,
    "profile_image_url_https":"https://si0.twimg.com/profile_images/1475168425/189391_2151954270770_1003770965_32544227_8147843_n_normal.jpg",
    "profile_image_url":"http://a3.twimg.com/profile_images/1475168425/189391_2151954270770_1003770965_32544227_8147843_n_normal.jpg",
    "name":"redban",
    "default_profile":false,
    "verified":false,
    "utc_offset":-28800,
    "friends_count":1074,
    "profile_link_color":"0084B4",
    "followers_count":26651,
    "screen_name":"redban",
    "default_profile_image":false,
    "profile_sidebar_border_color":"a8c7f7",
    "location":"Burbank, CA",
    "time_zone":"Pacific Time (US & Canada)",
    "status":
    {
        "favorited":false,
        "in_reply_to_status_id_str":"98986315491713024",
        "place":null,"in_reply_to_screen_name":"WarriorPoetUS",
        "in_reply_to_user_id_str":"105196298",
        "contributors":null,
        "geo":null,
        "retweeted":false,
        "truncated":false,
        "coordinates":null,
        "text":"@WarriorPoetUS I feel blessed just knowing you brotha!",
        "in_reply_to_user_id":105196298,
        "retweet_count":0,
        "in_reply_to_status_id":98986315491713024,
        "id_str":"99002282691137536",
        "source":"<a href=\"http://twitter.com/#!/download/iphone\" rel=\"nofollow\">Twitter for iPhone</a>",
        "created_at":"Thu Aug 04 06:22:38 +0000 2011",
        "id":99002282691137536
    },
    "is_translator":false,
    "following":false,
    "profile_use_background_image":true,
    "url":"http://www.redban.com",
    "description":"If you know me, you're paying attention. For all the podcasts I produce check out: http://www.deathsquad.tv and subscribe to DEATHSQUAD on iTunes.",
    "show_all_inline_media":true,
    "follow_request_sent":false,
    "geo_enabled":false,
    "profile_background_color":"022330",
    "id_str":"14829533",
    "profile_background_image_url":"http://a0.twimg.com/profile_background_images/188153775/redbak.jpg",
    "created_at":"Mon May 19 06:48:27 +0000 2008",
    "notifications":false,
    "id":14829533,
    "contributors_enabled":false,
    "statuses_count":5753,
    "favourites_count":71,
    "profile_text_color":"333333"
},

{
    "show_all_inline_media":false,
    "geo_enabled":false,
    "profile_sidebar_fill_color":"DDEEF6",
    "protected":false,
    "profile_image_url_https":"https://si0.twimg.com/profile_images/295809307/doc_normal.jpg",
    "lang":"en",
    "profile_background_tile":false,
    "profile_image_url":"http://a1.twimg.com/profile_images/295809307/doc_normal.jpg",
    "name":"Joey CoCo Diaz",
    "verified":false,
    "friends_count":99,
    "default_profile_image":false,
    "statuses_count":3440,
    "utc_offset":-28800,
    "profile_link_color":"0084B4",
    "followers_count":26489,
    "screen_name":"madflavor",
    "profile_sidebar_border_color":"C0DEED",
    "location":"Los Angeles CALIFORNIA",
    "is_translator":false,
    "time_zone":"Pacific Time (US & Canada)",
    "status":
    {
        "favorited":false,
        "in_reply_to_status_id_str":"99014475436408833",
        "place":null,
        "in_reply_to_screen_name":"msunner1",
        "in_reply_to_user_id_str":"308440624",
        "contributors":null,
        "geo":null,
        "retweeted":false,
        "truncated":false,
        "coordinates":null,
        "text":"@msunner1 Real soon! Much love!",
        "in_reply_to_user_id":308440624,
        "retweet_count":0,
        "in_reply_to_status_id":99014475436408833,
        "id_str":"99029735958511616",
        "source":"web",
        "created_at":"Thu Aug 04 08:11:43 +0000 2011",
        "id":99029735958511616
    },
    "follow_request_sent":false,
    "following":false,
    "profile_use_background_image":true,
    "url":"http://blogs.myspace.com/39708886",
    "description":"LIFECOACH/COMEDIAN/ CRIMINAL/ WEIGHTWATCHER",
    "profile_background_color":"C0DEED",
    "id_str":"29226377",
    "profile_background_image_url":"http://a0.twimg.com/images/themes/theme1/bg.png",
    "created_at":"Mon Apr 06 15:49:20 +0000 2009",
    "contributors_enabled":false,
    "notifications":false,
    "id":29226377,
    "default_profile":true,
    "listed_count":547,
    "profile_background_image_url_https":"https://si0.twimg.com/images/themes/theme1/bg.png",
    "favourites_count":3,
    "profile_text_color":"333333"
}]
  • 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-24T08:08:17+00:00Added an answer on May 24, 2026 at 8:08 am
    respond_to do |format|
      format.html 
      format.json { render :json => @users.map{|u| {:id => u.id, :screen_name => u.screen_name}} }
    end
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to take a csv file and import this data into a multi-dimensional
I have into $_POST array all the data i need. If I print_r the
I need to take an array that looks something like ... array( 11 =>
I need to take production data with real customer info (names, address, phone numbers,
I need to take an existing xml file, and modify just a few attributes
I need to take an existing winforms application and drop into an event tracing
I am writing some validation code. The code will take data passed into a
Need to take a SELECT drop down list options and find if any of
I need to take a web page and extract the address information from the
I need to take a paragraph of text and extract from it a list

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.