This code will do the job:
$args = array(
'post_type' => 'post',
'post_status' => 'publish',
'posts_per_page' => -1,
);
$query = new WP_Query( $args );
$posts = array();
$categories = array();
$json = array();
while( $query->have_posts() ) : $query->the_post();
$post_categories = get_the_category();
$post_category = current($post_categories);
$categories[] = array(
'name' => $post_category->name
);
$posts[] = array(
'title' => get_the_title(),
'excerpt' => get_the_excerpt(),
'author' => get_the_author(),
// I add additional data to export
'category' => $post_category->name
);
endwhile;
$categories = array_unique($categories);
$json['Categories'] = $categories;
$json['Posts'] = $posts;
$data = json_encode($json);