You can use get_the_content()
to fetch the post content, e.g.:
$content = get_the_content( $post_id );
Then you can pass it through the_content
filter and json encode
However, based on your comments, it looks like you’re creating an endpoint for AJAX calls that returns post content. Don’t bother! WordPress comes with one out of the box!
e.g.
https://tomjn.com/wp-json/wp/v2/posts/848
The response has a content
field and even contains a rendered
version that contains a fully rendered post as you desired.
You don’t need to do anything to get this, it’s already on your site at /wp-json