Wordpress json编码永久链接和图像

I'm making a query to encode in JSON a bunch of wordpress post data in this way:

$query = new WP_Query( $args ); 
$posts = $query->get_posts();   
foreach( $posts as $post ) {    
    $output[] = array( 'id' => $post->ID, 'title' => $post->post_title, 'count' => $post->custom_total_hits, 'soundcloud_url' => $post->soundcloud_song, 'soundcloud_id' => $post->soundcloud_ids);
}
echo json_encode($output);

But how can I add to my JSON also the permalink of the $post->ID and the url of the attached image? In order to have something like:

{
"id":28197,
"title":"Hazel English - More Like You",
"count":"000000421",
"soundcloud_url":"https:\/\/soundcloud.com\/hazelenglish\/hazel-english-more-like-you-2",
"soundcloud_id":"317317206",
"link":" ",
"image_url":" "
}

Look here: Permalink and Attached media

$query = new WP_Query( $args ); 
$posts = $query->get_posts(); 
foreach( $posts as $post ) { 
$output[] = array( 
'id' => $post->ID, 
'title' => $post->post_title, 
'count' => $post->custom_total_hits, 
'soundcloud_url' => $post->soundcloud_song, 
'soundcloud_id' => $post->soundcloud_ids, 
'link' => get_permalink($post), 
'images' => get_attached_media('image', $post->ID) );
 } 
echo json_encode($output);

As you can see in documentation, function get_attached_media return an array with all data of type selected from indicated post.