Skip to content

Commit

Permalink
Merge pull request #28 from rtfeldman/rename-core
Browse files Browse the repository at this point in the history
Rename Core.json to Json.utf8
  • Loading branch information
lukewilliamboswell authored May 4, 2024
2 parents d3f438a + 764f70f commit 715e4dd
Show file tree
Hide file tree
Showing 8 changed files with 115 additions and 117 deletions.
4 changes: 2 additions & 2 deletions examples/simple1.roc
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@ app [main] {

import cli.Task
import cli.Stdout
import json.Core
import json.Json

main =
requestBody = Str.toUtf8 "{\"Image\":{\"Animated\":false,\"Height\":600,\"Ids\":[116,943,234,38793],\"Thumbnail\":{\"Height\":125,\"Url\":\"http:\\/\\/www.example.com\\/image\\/481989943\",\"Width\":100},\"Title\":\"View from 15th Floor\",\"Width\":800}}"

decoder = Core.jsonWithOptions { fieldNameMapping: PascalCase }
decoder = Json.utf8With { fieldNameMapping: PascalCase }

decoded : Decode.DecodeResult ImageRequest
decoded = Decode.fromBytesPartial requestBody decoder
Expand Down
4 changes: 2 additions & 2 deletions examples/simple2.roc
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ app [main] {

import cli.Stdout
import cli.Task
import json.Core
import json.Json
import "data.json" as requestBody : List U8

main =
decoder = Core.jsonWithOptions {}
decoder = Json.utf8With {}

decoded : Decode.DecodeResult (List DataRequest)
decoded = Decode.fromBytesPartial requestBody decoder
Expand Down
4 changes: 2 additions & 2 deletions examples/tuple.roc
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@ app [main] {

import cli.Task
import cli.Stdout
import json.Core
import json.Json

main =
bytes = Str.toUtf8 "[ [ 123,\n\"apples\" ], [ 456, \"oranges\" ]]"

decoded : Decode.DecodeResult (List FruitCount)
decoded = Decode.fromBytesPartial bytes Core.json
decoded = Decode.fromBytesPartial bytes Json.utf8

when decoded.result is
Ok tuple -> Stdout.line! "Successfully decoded tuple, got $(toStr tuple)"
Expand Down
Loading

0 comments on commit 715e4dd

Please sign in to comment.