+ 'dfrn' => (object)['@id' => 'http://purl.org/macgirvin/dfrn/1.0/', '@type' => '@id'],
+ 'diaspora' => (object)['@id' => 'https://diasporafoundation.org/ns/', '@type' => '@id'],
+ 'ostatus' => (object)['@id' => 'http://ostatus.org#', '@type' => '@id'],
+ 'dc' => (object)['@id' => 'http://purl.org/dc/terms/', '@type' => '@id'],
+ 'toot' => (object)['@id' => 'http://joinmastodon.org/ns#', '@type' => '@id'],
+ 'litepub' => (object)['@id' => 'http://litepub.social/ns#', '@type' => '@id']];
+
+ // Preparation for adding possibly missing content to the context
+ if (!empty($json['@context']) && is_string($json['@context'])) {
+ $json['@context'] = [$json['@context']];
+ }
+
+ // Workaround for servers with missing context
+ // See issue https://github.com/nextcloud/social/issues/330
+ if (!empty($json['@context']) && is_array($json['@context'])) {
+ $json['@context'][] = 'https://w3id.org/security/v1';
+ }
+
+ // Trying to avoid memory problems with large content fields
+ if (!empty($json['object']['source']['content'])) {
+ $content = $json['object']['source']['content'];
+ $json['object']['source']['content'] = '';
+ }
+
+ $jsonobj = json_decode(json_encode($json, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE));