You're supposed to use an off-the-shelf XML/JSON parser, not write it yourself.
That's basically a description of ActivityPub that wraps HTML in JSON!
<body> markdown text </body>