8000 Add application/ld+json format associated to json by vincentchalamon · Pull Request #25599 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

Add application/ld+json format associated to json #25599

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Add application/ld+json format associated to json
  • Loading branch information
vincentchalamon committed Dec 24, 2017
commit 1056bf200cb92cf7528f0f97ad156c9063b88f3f
2 changes: 1 addition & 1 deletion src/Symfony/Component/HttpFoundation/Request.php
Original file line number Diff line number Diff line change
Expand Up @@ -1875,7 +1875,7 @@ protected static function initializeFormats()
'txt' => array('text/plain'),
'js' => array('application/javascript', 'application/x-javascript', 'text/javascript'),
'css' => array('text/css'),
'json' => array('application/json', 'application/x-json'),
'json' => array('application/json', 'application/x-json', 'application/ld+json'),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

JSON-LD documents are indeed valid JSON, but all JSON documents aren't valid JSON-LD ones. They are different format, so we should introduce a new key for application/ld+json. I suggest to use jsonld, because it is already used in API Platform.

'xml' => array('text/xml', 'application/xml', 'application/x-xml'),
'rdf' => array('application/rdf+xml'),
'atom' => array('application/atom+xml'),
Expand Down
2 changes: 1 addition & 1 deletion src/Symfony/Component/HttpFoundation/Tests/RequestTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,7 @@ public function getFormatToMimeTypeMapProvider()
array('txt', array('text/plain')),
array('js', array('application/javascript', 'application/x-javascript', 'text/javascript')),
array('css', array('text/css')),
array('json', array('application/json', 'application/x-json')),
array('json', array('application/json', 'application/x-json', 'application/ld+json')),
array('xml', array('text/xml', 'application/xml', 'application/x-xml')),
array('rdf', array('application/rdf+xml')),
array('atom', array('application/atom+xml')),
Expand Down
0