Skip to content

Instantly share code, notes, and snippets.

@takaheraw
Last active February 11, 2016 12:22
Show Gist options
  • Save takaheraw/7a2342f58b74771bd828 to your computer and use it in GitHub Desktop.
Save takaheraw/7a2342f58b74771bd828 to your computer and use it in GitHub Desktop.
$ cat tweet.json | jq -c ' .[] |
{
  id:                     .id_str,
  created_at:             .created_at,
  text:                   .text,
  analyze_text:           .text,
  source:                 .source,
  in_reply: {
    status:               .in_reply_to_status_id_str,
    user_id:              .in_reply_to_user_id_str,
    screen_name:          .in_reply_to_screen_name
  },
  user: {
    id:                   .user.id_str,
    name:                 .user.name,
    screen_name:          .user.screen_name,
    location:             .user.location,
    description:          .user.description,
    url:                  .user.url,
    followers_count:      .user.followers_count,
    friends_count:        .user.friends_count,
    listed_count:         .user.listed_count,
    created_at:           .user.created_at,
    favourites_count:     .user.favourites_count,
    statuses_count:       .user.statuses_count,
    lang:                 .user.lang,
    profile_image_url:    .user.profile_image_url_https,
    profile_banner_url:   .user.profile_banner_url
  },
  geo: {
    lat:                  (.geo.coordinates[0] // 0),
    lon:                  (.geo.coordinates[1] // 0)
  },
  place: {
    id:                   .place.id,
    url:                  .place.url,
    place_type:           .place.place_type,
    name:                 .place.name,
    full_name:            .place.full_name,
    country_code:         .place.country_code,
    country:              .place.country
  },
  retweet_count:          .retweet_count,
  favorite_count:         .favorite_count,
  lang:                   .lang,
  hashtags:               .entities.hashtags,
  user_mentions:          .entities.user_mentions,
  media:                  .entities.media,
  retweeted_status: {
    created_at:           .retweeted_status.created_at,
    id:                   .retweeted_status.id_str,
    text:                 .retweeted_status.text,
    source:               .retweeted_status.source,
    in_reply: {
      status:             .retweeted_status.in_reply_to_status_id_str,
      user_id:            .retweeted_status.in_reply_to_user_id_str,
      screen_name:        .retweeted_status.in_reply_to_screen_name
    },
    user: {
      id:                 .retweeted_status.user.id_str,
      name:               .retweeted_status.user.name,
      screen_name:        .retweeted_status.user.screen_name,
      location:           .retweeted_status.user.location,
      description:        .retweeted_status.user.description,
      url:                .retweeted_status.user.url,
      followers_count:    .retweeted_status.user.followers_count,
      friends_count:      .retweeted_status.user.friends_count,
      listed_count:       .retweeted_status.user.listed_count,
      created_at:         .retweeted_status.user.created_at,
      favourites_count:   .retweeted_status.user.favourites_count,
      statuses_count:     .retweeted_status.user.statuses_count,
      lang:               .retweeted_status.user.lang,
      profile_image_url:  .retweeted_status.user.profile_image_url_https,
      profile_banner_url: .retweeted_status.user.profile_banner_url
    }
  },
  quoted_status: {
    created_at:           .quoted_status.created_at,
    id:                   .quoted_status.id_str,
    text:                 .quoted_status.text,
    source:               .quoted_status.source,
    in_reply: {
      status:             .quoted_status.in_reply_to_status_id_str,
      user_id:            .quoted_status.in_reply_to_user_id_str,
      screen_name:        .quoted_status.in_reply_to_screen_name
    },
    user: {
      id:                 .quoted_status.user.id_str,
      name:               .quoted_status.user.name,
      screen_name:        .quoted_status.user.screen_name,
      location:           .quoted_status.user.location,
      description:        .quoted_status.user.description,
      url:                .quoted_status.user.url,
      followers_count:    .quoted_status.user.followers_count,
      friends_count:      .quoted_status.user.friends_count,
      listed_count:       .quoted_status.user.listed_count,
      created_at:         .quoted_status.user.created_at,
      favourites_count:   .quoted_status.user.favourites_count,
      statuses_count:     .quoted_status.user.statuses_count,
      lang:               .quoted_status.user.lang,
      profile_image_url:  .quoted_status.user.profile_image_url_https,
      profile_banner_url: .quoted_status.user.profile_banner_url
    }
  }
}
'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment