-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #37 from lukewilliamboswell/fix-unicode
Fix unicode
- Loading branch information
Showing
5 changed files
with
122 additions
and
49 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
examples/optional | ||
examples/simple1 | ||
examples/simple2 | ||
examples/tuple | ||
.DS_Store | ||
generated-docs/ | ||
generated-docs/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,37 +1,37 @@ | ||
app [main] { | ||
cli: platform "https://github.com/roc-lang/basic-cli/releases/download/0.15.0/SlwdbJ-3GR7uBWQo6zlmYWNYOxnvo8r6YABXD-45UOw.tar.br", | ||
json: "../package/main.roc", # use release URL (ends in tar.br) for local example, see github.com/lukewilliamboswell/roc-json/releases | ||
} | ||
|
||
import cli.Stdout | ||
import json.Json | ||
import "data.json" as requestBody : List U8 | ||
|
||
main = | ||
decoder = Json.utf8With {} | ||
|
||
decoded : Decode.DecodeResult (List DataRequest) | ||
decoded = Decode.fromBytesPartial requestBody decoder | ||
|
||
when decoded.result is | ||
Ok list -> | ||
Stdout.line! "Successfully decoded list" | ||
|
||
when List.get list 0 is | ||
Ok rec -> Stdout.line! "Name of first person is: $(rec.lastname)" | ||
Err _ -> Stdout.line! "Error occurred in List.get" | ||
|
||
Err TooShort -> Stdout.line! "A TooShort error occurred" | ||
|
||
DataRequest : { | ||
id : I64, | ||
firstname : Str, | ||
lastname : Str, | ||
email : Str, | ||
gender : Str, | ||
ipaddress : Str, | ||
} | ||
|
||
# => | ||
# Successfully decoded list | ||
# Name of first person is: Penddreth | ||
app [main] { | ||
cli: platform "https://github.com/roc-lang/basic-cli/releases/download/0.15.0/SlwdbJ-3GR7uBWQo6zlmYWNYOxnvo8r6YABXD-45UOw.tar.br", | ||
json: "../package/main.roc", # use release URL (ends in tar.br) for local example, see github.com/lukewilliamboswell/roc-json/releases | ||
} | ||
|
||
import cli.Stdout | ||
import json.Json | ||
import "data.json" as requestBody : List U8 | ||
|
||
main = | ||
decoder = Json.utf8With {} | ||
|
||
decoded : Decode.DecodeResult (List DataRequest) | ||
decoded = Decode.fromBytesPartial requestBody decoder | ||
|
||
when decoded.result is | ||
Ok list -> | ||
Stdout.line! "Successfully decoded list" | ||
|
||
when List.get list 0 is | ||
Ok rec -> Stdout.line! "Name of first person is: $(rec.lastname)" | ||
Err _ -> Stdout.line! "Error occurred in List.get" | ||
|
||
Err TooShort -> Stdout.line! "A TooShort error occurred" | ||
|
||
DataRequest : { | ||
id : I64, | ||
firstname : Str, | ||
lastname : Str, | ||
email : Str, | ||
gender : Str, | ||
ipaddress : Str, | ||
} | ||
|
||
# => | ||
# Successfully decoded list | ||
# Name of first person is: Penddreth |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters