[MGNLREST-217] JSON response should be pretty printed Created: 19/Nov/19  Updated: 04/Apr/22

Status: Accepted
Project: Magnolia REST Framework
Component/s: None
Affects Version/s: 2.1.3
Fix Version/s: None

Type: Improvement Priority: Neutral
Reporter: Christopher Zimmermann Assignee: Unassigned
Resolution: Unresolved Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Relates
relates to MGNLDEMO-328 Delivery endpoint responses are missi... Open
Template:
Acceptance criteria:
Empty
Task DoD:
[ ]* Doc/release notes changes? Comment present?
[ ]* Downstream builds green?
[ ]* Solution information and context easily available?
[ ]* Tests
[ ]* FixVersion filled and not yet released
[ ]  Architecture Decision Record (ADR)
Date of First Response:
Epic Link: Headless Backlog

 Description   

The JSON returned by the delivery endpoint has been 'minified' by removing all whitespace and line break characters.

The advantage of slightly smaller filesize is outweighed by the disadvantage of being harder to inspect and work with as a developer.

The default behaviour should be to output the response with nice indentation and line breaks (often referred to as 'pretty printed'). (Our competitors do this.)

Consider adding a short parameter which would cause the output to be minified.



 Comments   
Comment by Bartosz Staryga [ 12/Feb/20 ]

Should the min version be default and pretty printed one achieved via parameter?
Most devs I know they have some formatter installed as extension in browser so this solves the issue.

Comment by Christopher Zimmermann [ 17/Dec/21 ]

I think pretty printed should be the default, otherwise I dont think anyone would ever use it.
You are correct that developers have tools to get the output prettyprinted, but its often an extra hassle.

I think the benefit to developer experience outweighs the small extra "weight" on the response. 5%? And the devs that want the minification will look for the feature and use it.

Comment by Bartosz Staryga [ 17/Dec/21 ]

I have JSON prettier installed since Chrome has extensions so never really worried about it, but if it really is an issue, it can be configurable

Generated at Mon Feb 12 06:57:47 CET 2024 using Jira 9.4.2#940002-sha1:46d1a51de284217efdcb32434eab47a99af2938b.