Unmarshalling and (re)marshalling the message will do that for you. https://play.golang.org/p/UrHedCa6sO
You get error checking and reformatting for free. //jb On 11 Jul 2017, at 20:57, Tong Sun <suntong...@gmail.com<mailto:suntong...@gmail.com>> wrote: Hi, Is there any existing code/package out there that can sort an arbitrary json string in all its nesting levels, so that the attributes at any level are in sorted order? thx. -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com<mailto:golang-nuts+unsubscr...@googlegroups.com>. For more options, visit https://groups.google.com/d/optout. -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.