Skip to content
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

Open
wants to merge 7 commits into
base: main
Choose a base branch
from

Conversation

smores56
Copy link
Contributor

@smores56 smores56 commented Jan 7, 2025

No description provided.

use std::convert::Infallible;

async fn handle_request(_req: Request<Body>) -> Result<Response<Body>, Infallible> {
// Encode.to_bytes {foo: "Hello Json!"} Json.utf8
Copy link
Contributor Author

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}
Copy link
Contributor Author

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}
Copy link
Contributor Author

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"}
Copy link
Contributor Author

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",}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

noneJson -> none_json

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants