go-edn / edn

Go implementation of EDN (Extensible Data Notation)
BSD 3-Clause "New" or "Revised" License
110 stars 11 forks source link

Pretty print edn when marshalling #24

Open ghost opened 4 years ago

ghost commented 4 years ago

Is it possible to marshal edn data into nicely formatted string? Currently MarshelIndent produces this:

{
  :deps {
    io.netty/netty-buffer {
      :mvn/version "4.1.30.Final"
    },
    potemkin {
      :mvn/version "0.4.5"
    }
  }
}

when I want this:

{:deps    {potemkin              {:mvn/version "0.4.5"}
           io.netty/netty-buffer {:mvn/version "4.1.30.Final"}}}
hypirion commented 4 years ago

@fctorial: Hi! Sorry for being slow to reply here: It's possible to use MarshalPPrint or PPrint to get a similar, but not quite identical result. For your input, PPrint would generate

{:deps {io.netty/netty-buffer {:mvn/version "4.1.30.Final"},
        potemkin {:mvn/version "0.4.5"}}}

or potemkin before io.netty, depending on how you input the data.

See https://play.golang.org/p/8FWtHZgWf39 for code