-
Notifications
You must be signed in to change notification settings - Fork 13
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
Update to snake_case and PNC #42
base: main
Are you sure you want to change the base?
Conversation
use std::convert::Infallible; | ||
|
||
async fn handle_request(_req: Request<Body>) -> Result<Response<Body>, Infallible> { | ||
// Encode.to_bytes {foo: "Hello Json!"} Json.utf8 |
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.
PNC
# nullJson == {"firstName":"Luke","lastName":null} | ||
nullJson = Encode.toBytes nullObj Json.utf8 | ||
Stdout.line! (nullJson |> Str.fromUtf8 |> Result.withDefault "Failed to encode JSON") | ||
# nullJson == {"first_name":"Luke","last_name":null} |
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.
nullJson -> null_json
# nullNoneJson == {"firstName":"Luke","lastName":null} | ||
nullNoneJson = Encode.toBytes noneObj (Json.utf8With { emptyEncodeAsNull: Json.encodeAsNullOption { record: Bool.true } }) | ||
Stdout.line! (nullNoneJson |> Str.fromUtf8 |> Result.withDefault "Failed to encode JSON") | ||
# nullNoneJson == {"first_name":"Luke","last_name":null} |
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.
nullNoneJson -> null_none_json
# someJson == {"firstName":"Luke","lastName":"Boswell"} | ||
someJson = Encode.toBytes someObj Json.utf8 | ||
Stdout.line (someJson |> Str.fromUtf8 |> Result.withDefault "Failed to encode JSON") | ||
# someJson == {"first_name":"Luke","last_name":"Boswell"} |
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.
someJson -> some_json
# noneJson == {"firstName":"Luke",} | ||
noneJson = Encode.toBytes noneObj (Json.utf8With { emptyEncodeAsNull: Json.encodeAsNullOption { record: Bool.false } }) | ||
Stdout.line! (noneJson |> Str.fromUtf8 |> Result.withDefault "Failed to encode JSON") | ||
# noneJson == {"first_name":"Luke",} |
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.
noneJson -> none_json
No description provided.