Hello all,

I have recently worked with the SecureScuttlebutt group on implementing 
their feeds.
One of their requirements is to sign JSON messages. Instead of removing all 
whitespace, they decided to use a pretty printer to format the message.

They mention when pretty printing the JSON that they use a specific format 
after this 
specification: 
https://www.ecma-international.org/ecma-262/6.0/#sec-json.stringify

I'll confess that I don't quite get the algorithm in there. Helpfully, the 
SSB protocol guide 
(https://ssbc.github.io/scuttlebutt-protocol-guide/#message-format) spells 
it out for me:

In brief, the rules are:
>    
>    - Two spaces for indentation.
>
>
>    - Dictionary entries and list elements each on their own line.
>
>
>    - Empty dictionaries appear as {} and empty lists appear as [].
>
>
>    - One space after the colon : for dictionary keys.
>
>
>    - Strings and numbers formatted according to the sections *QuoteJSONString 
>    <https://www.ecma-international.org/ecma-262/6.0/#sec-quotejsonstring>*
>     and *ToString Applied to the Number Type 
>    
> <https://www.ecma-international.org/ecma-262/6.0/#sec-tostring-applied-to-the-number-type>*
>    .
>
>
>    - No trailing newline.
>
> Or, from their tests, they apply this function:

> JSON.stringify(msg, null, 2)


I believe the indentation rule is custom to SSB. I also am chasing them on 
the newline character used (they say it's `\n`). All those rules matter 
since they're using those rules to sign data.

That said, would the Jackson community be interested in using this format 
(with the possibility to dictate different indent characters, different 
newlines) as a pretty printer?

Cheers,

Antoine

-- 
You received this message because you are subscribed to the Google Groups 
"jackson-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to