Skip to content

Consider supporting "compact-pretty-printed" mode #586

@nyurik

Description

@nyurik

Would it be possible to support json_pretty_compact-style formatting? From that crate's example - note how it tries to fit as many elements on a single line as possible, and only when it can't fit more, it inserts a line break. This implies a back-tracking algorithm - for each sub-tree, render it as a one-liner until it no longer fits, otherwise backtrack and break into multiple lines

[
  {
    "name": { "first": "Kobe", "middle": "Nico", "last": "Grimes" },
    "phoneNumber": "1-547-479-5471 x062",
    "username": "Kobe-Grimes",
    "emails": [ "Melyssa.Cremin4@gmail.com", "Jayne.Green37@gmail.com" ],
    "coordinates": { "latitude": "-66.3821", "longitude": "127.117" }
  },
  {
    "name": { "first": "Adrian", "middle": "Finley", "last": "Koch" },
    "phoneNumber": "1-420-853-5251 x68083",
    "username": "Adrian-Koch",
    "emails": [ "Andy99@gmail.com", "Elenor.Aufderhar96@gmail.com" ],
    "coordinates": { "latitude": "51.4003", "longitude": "3.351" }
  }
]

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions