feat: More compact JSON formatting in the FileViewer#326
Merged
allison-truhlar merged 1 commit intoJaneliaSciComp:mainfrom Mar 13, 2026
Merged
feat: More compact JSON formatting in the FileViewer#326allison-truhlar merged 1 commit intoJaneliaSciComp:mainfrom
allison-truhlar merged 1 commit intoJaneliaSciComp:mainfrom
Conversation
Replace JSON.stringify with FracturedJson formatter for more compact, readable output — short arrays and small objects stay on one line. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
allison-truhlar
approved these changes
Mar 13, 2026
Collaborator
allison-truhlar
left a comment
There was a problem hiding this comment.
Looks good, thanks Stuart! This was an outstanding issue from this previous PR: #280 (comment)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This is a small thing, but on a whim I asked my friend Claude O to give it a try. (Sadly, it didn't 1-shot the implementation, but it was close.)
I don't like reading unformatted JSON, but I also don't love the maximally-expanded JSON that most "pretty printing" functions produce.
The FracturedJsonJs library produces something I like better. It includes some options to control exactly how it formats JSON, but in this PR, I'm mostly using the defaults.
Example:
plain indented formatting (old)
{ "janelia": { "projections": { "0": { "xy": "projections/zMAX-NP08_R2_2_1_SS83741_Gpb5_546_ITP_647_1x_LOL.png" } } }, "multiscales": [ { "axes": [ { "name": "t", "type": "time" }, { "name": "c", "type": "channel" }, { "name": "z", "type": "space", "unit": "micrometer" }, { "name": "y", "type": "space", "unit": "micrometer" }, { "name": "x", "type": "space", "unit": "micrometer" } ], "datasets": [ { "coordinateTransformations": [ { "scale": [ 1, 1, 0.42589198869287453, 0.23296123369249422, 0.23296123369249422 ], "type": "scale" } ], "path": "0" }, { "coordinateTransformations": [ { "scale": [ 1, 1, 0.42589198869287453, 0.46592246738498844, 0.46592246738498844 ], "type": "scale" } ], "path": "1" }, { "coordinateTransformations": [ { "scale": [ 1, 1, 0.42589198869287453, 0.9318449347699769, 0.9318449347699769 ], "type": "scale" } ], "path": "2" }, { "coordinateTransformations": [ { "scale": [ 1, 1, 0.42589198869287453, 1.8636898695399537, 1.8636898695399537 ], "type": "scale" } ], "path": "3" } ], "metadata": { "method": "loci.common.image.SimpleImageScaler", "version": "Bio-Formats 7.2.0" }, "name": "", "version": "0.4" } ], "omero": { "channels": [ { "active": true, "coefficient": 1, "color": "00FF00", "family": "linear", "inverted": false, "label": "Cam1-T1", "window": { "end": 12282, "max": 12282, "min": 40, "start": 40 } }, { "active": true, "coefficient": 1, "color": "FF00FF", "family": "linear", "inverted": false, "label": "Cam2-T1", "window": { "end": 65535, "max": 65535, "min": 72, "start": 72 } }, { "active": true, "coefficient": 1, "color": "FF0000", "family": "linear", "inverted": false, "label": "Cam2-T2", "window": { "end": 8176, "max": 8176, "min": 60, "start": 60 } }, { "active": false, "coefficient": 1, "color": "00FFFF", "family": "linear", "inverted": false, "label": "Cam1-T3", "window": { "end": 18116, "max": 18116, "min": 82, "start": 82 } } ], "rdefs": { "defaultT": 0, "defaultZ": 333, "model": "color" } } }formatted with FracturedJson (new)
{ "janelia" : { "projections": { "0": {"xy": "projections/zMAX-NP08_R2_2_1_SS83741_Gpb5_546_ITP_647_1x_LOL.png"} } }, "multiscales": [ { "axes" : [ {"name": "t", "type": "time" }, {"name": "c", "type": "channel" }, {"name": "z", "type": "space", "unit": "micrometer"}, {"name": "y", "type": "space", "unit": "micrometer"}, {"name": "x", "type": "space", "unit": "micrometer"} ], "datasets": [ { "coordinateTransformations": [ { "scale": [1, 1, 0.42589198869287453, 0.23296123369249422, 0.23296123369249422], "type": "scale" } ], "path": "0" }, { "coordinateTransformations": [ { "scale": [1, 1, 0.42589198869287453, 0.46592246738498844, 0.46592246738498844], "type": "scale" } ], "path": "1" }, { "coordinateTransformations": [ { "scale": [1, 1, 0.42589198869287453, 0.9318449347699769, 0.9318449347699769], "type": "scale" } ], "path": "2" }, { "coordinateTransformations": [ { "scale": [1, 1, 0.42589198869287453, 1.8636898695399537, 1.8636898695399537], "type": "scale" } ], "path": "3" } ], "metadata": {"method": "loci.common.image.SimpleImageScaler", "version": "Bio-Formats 7.2.0"}, "name" : "", "version" : "0.4" } ], "omero" : { "channels": [ { "active" : true, "coefficient": 1, "color" : "00FF00", "family" : "linear", "inverted" : false, "label" : "Cam1-T1", "window" : {"end": 12282, "max": 12282, "min": 40, "start": 40} }, { "active" : true, "coefficient": 1, "color" : "FF00FF", "family" : "linear", "inverted" : false, "label" : "Cam2-T1", "window" : {"end": 65535, "max": 65535, "min": 72, "start": 72} }, { "active" : true, "coefficient": 1, "color" : "FF0000", "family" : "linear", "inverted" : false, "label" : "Cam2-T2", "window" : {"end": 8176, "max": 8176, "min": 60, "start": 60} }, { "active" : false, "coefficient": 1, "color" : "00FFFF", "family" : "linear", "inverted" : false, "label" : "Cam1-T3", "window" : {"end": 18116, "max": 18116, "min": 82, "start": 82} } ], "rdefs" : {"defaultT": 0, "defaultZ": 333, "model": "color"} } }