-
Notifications
You must be signed in to change notification settings - Fork 97
Sort JSON by keys [ESD-1169] #664
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
@mfine How big task would it be to add similar option to haskell |
|
@pmiettinen there's a module aeson-pretty that can sort the JSON keys on encoding. But do you need to build it into the utilities? ➜ c/tests/data git:(bf2cf4b) cat nmea.sbp | sbp2json | head -2
{"length":24,"status":0,"preamble":85,"sender":48492,"msg_type":175,"setting":"udp_server1\u0000port\u000055558\u0000","payload":"AHVkcF9zZXJ2ZXIxAHBvcnQANTU1NTgA","crc":29999}
{"length":64,"status":0,"preamble":85,"sender":48492,"msg_type":175,"setting":"udp_client0\u0000mode\u0000Disabled\u0000enum:Disabled,RTCMv3 IN,NMEA OUT,SBP\u0000","payload":"AHVkcF9jbGllbnQwAG1vZGUARGlzYWJsZWQAZW51bTpEaXNhYmxlZCxSVENNdjMgSU4sTk1FQSBPVVQsU0JQAA==","crc":58399}
➜ c/tests/data git:(bf2cf4b) cat nmea.sbp | sbp2json | head -2 | jq -rcS
{"crc":29999,"length":24,"msg_type":175,"payload":"AHVkcF9zZXJ2ZXIxAHBvcnQANTU1NTgA","preamble":85,"sender":48492,"setting":"udp_server1\u0000port\u000055558\u0000","status":0}
{"crc":58399,"length":64,"msg_type":175,"payload":"AHVkcF9jbGllbnQwAG1vZGUARGlzYWJsZWQAZW51bTpEaXNhYmxlZCxSVENNdjMgSU4sTk1FQSBPVVQsU0JQAA==","preamble":85,"sender":48492,"setting":"udp_client0\u0000mode\u0000Disabled\u0000enum:Disabled,RTCMv3 IN,NMEA OUT,SBP\u0000","status":0}
➜ c/tests/data git:(bf2cf4b) |
|
@mfine I think I found the |
|
@pmiettinen the SBP2JSON doesn't take options presently (at the time, that was the idea to keep it simple and based on stdin stdout - probably should have added options support). To keep things as they are, you could do a SBP2PRETTYJSON or something, similar to SBP2JSON, but change the encoding to use aseon-pretty: https://github.com/swift-nav/libsbp/blob/master/haskell/main/SBP2JSON.hs#L28 |
c0e9a8b to
bd18311
Compare
|
@mfine |
mfine
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yup, that's the idea - good job!
a6ef6e9 to
bc79542
Compare
|
Would prefer if we can make this a CLI switch for Haskell somehow and expose the Python option through a switch to (I guess) |
|
I'm good with the separate binary for Haskell. |
|
ok, we'll go with your preference @mfine |
Sorting is not done by default to avoid decrease in efficiency.