-
-
Notifications
You must be signed in to change notification settings - Fork 174
Open
Description
Current the only options for rendering JSON is minified:
{"a":{"a":1,"b":2,"c":3,"d":4,"e":5,"f":6},"b":{"a":1,"b":2,"c":3,"d":4,"e":5,"f":6},"c":{"a":1,"b":2,"c":3,"d":4,"e":5,"f":6},"d":{"a":1,"b":2,"c":3,"d":4,"e":5,"f":6},"e":{"a":1,"b":2,"c":3,"d":4,"e":5,"f":6},"f":{"a":1,"b":2,"c":3,"d":4,"e":5,"f":6}}and indented/fully-vertically-expanded
{
"a": {
"a": 1,
"b": 2,
"c": 3,
"d": 4,
"e": 5,
"f": 6
},
"b": {
"a": 1,
"b": 2,
"c": 3,
"d": 4,
"e": 5,
"f": 6
},
"c": {
"a": 1,
"b": 2,
"c": 3,
"d": 4,
"e": 5,
"f": 6
},
"d": {
"a": 1,
"b": 2,
"c": 3,
"d": 4,
"e": 5,
"f": 6
},
"e": {
"a": 1,
"b": 2,
"c": 3,
"d": 4,
"e": 5,
"f": 6
},
"f": {
"a": 1,
"b": 2,
"c": 3,
"d": 4,
"e": 5,
"f": 6
}
}We should add a third option where you provide a max column width, and it one-lines the output JSON until it reaches the column width before wrapping:
# max columns = 60 |
{
"a": {"a": 1, "b": 2, "c": 3, "d": 4, "e": 5, "f": 6},
"b": {"a": 1, "b": 2, "c": 3, "d": 4, "e": 5, "f": 6},
"c": {"a": 1, "b": 2, "c": 3, "d": 4, "e": 5, "f": 6},
"d": {"a": 1, "b": 2, "c": 3, "d": 4, "e": 5, "f": 6},
"e": {"a": 1, "b": 2, "c": 3, "d": 4, "e": 5, "f": 6},
"f": {"a": 1, "b": 2, "c": 3, "d": 4, "e": 5, "f": 6}
}This would be the most tricky to implement efficiently v.s. minification or naive multi-lining, but would be the superior format for anything meant for human reading (e.g. logs, config files, etc.). This can probably be done by the same algorithm we use in com-lihaoyi/pprint, described here http://www.lihaoyi.com/post/CompactStreamingPrettyPrintingofHierarchicalData.html, though it would need to be adapted to work in a "push" style to fit into a upickle.core.Visitor
Metadata
Metadata
Assignees
Labels
No labels