@grain/stdlib 0.5.13 → 0.6.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (155) hide show
  1. package/CHANGELOG.md +201 -0
  2. package/LICENSE +1 -1
  3. package/README.md +25 -2
  4. package/array.gr +1512 -199
  5. package/array.md +2032 -94
  6. package/bigint.gr +239 -140
  7. package/bigint.md +450 -106
  8. package/buffer.gr +595 -102
  9. package/buffer.md +903 -145
  10. package/bytes.gr +401 -110
  11. package/bytes.md +551 -63
  12. package/char.gr +228 -49
  13. package/char.md +373 -7
  14. package/exception.gr +26 -12
  15. package/exception.md +29 -5
  16. package/float32.gr +130 -109
  17. package/float32.md +185 -57
  18. package/float64.gr +112 -99
  19. package/float64.md +185 -57
  20. package/hash.gr +62 -40
  21. package/hash.md +27 -3
  22. package/int16.gr +430 -0
  23. package/int16.md +618 -0
  24. package/int32.gr +200 -269
  25. package/int32.md +254 -289
  26. package/int64.gr +142 -225
  27. package/int64.md +254 -289
  28. package/int8.gr +511 -0
  29. package/int8.md +786 -0
  30. package/json.gr +2071 -0
  31. package/json.md +646 -0
  32. package/list.gr +120 -68
  33. package/list.md +125 -80
  34. package/map.gr +560 -57
  35. package/map.md +672 -56
  36. package/marshal.gr +239 -227
  37. package/marshal.md +36 -4
  38. package/number.gr +626 -676
  39. package/number.md +738 -153
  40. package/option.gr +33 -35
  41. package/option.md +58 -42
  42. package/package.json +2 -2
  43. package/path.gr +148 -187
  44. package/path.md +47 -96
  45. package/pervasives.gr +75 -416
  46. package/pervasives.md +85 -180
  47. package/priorityqueue.gr +433 -74
  48. package/priorityqueue.md +422 -54
  49. package/queue.gr +362 -80
  50. package/queue.md +433 -38
  51. package/random.gr +67 -75
  52. package/random.md +68 -40
  53. package/range.gr +135 -63
  54. package/range.md +198 -43
  55. package/rational.gr +284 -0
  56. package/rational.md +545 -0
  57. package/regex.gr +933 -1066
  58. package/regex.md +59 -60
  59. package/result.gr +23 -25
  60. package/result.md +54 -39
  61. package/runtime/atof/common.gr +78 -82
  62. package/runtime/atof/common.md +22 -10
  63. package/runtime/atof/decimal.gr +102 -127
  64. package/runtime/atof/decimal.md +28 -7
  65. package/runtime/atof/lemire.gr +56 -71
  66. package/runtime/atof/lemire.md +9 -1
  67. package/runtime/atof/parse.gr +83 -110
  68. package/runtime/atof/parse.md +12 -2
  69. package/runtime/atof/slow.gr +28 -35
  70. package/runtime/atof/slow.md +9 -1
  71. package/runtime/atof/table.gr +19 -18
  72. package/runtime/atof/table.md +10 -2
  73. package/runtime/atoi/parse.gr +153 -136
  74. package/runtime/atoi/parse.md +50 -1
  75. package/runtime/bigint.gr +410 -517
  76. package/runtime/bigint.md +71 -57
  77. package/runtime/compare.gr +176 -85
  78. package/runtime/compare.md +31 -1
  79. package/runtime/dataStructures.gr +144 -32
  80. package/runtime/dataStructures.md +267 -31
  81. package/runtime/debugPrint.gr +34 -15
  82. package/runtime/debugPrint.md +37 -5
  83. package/runtime/equal.gr +53 -52
  84. package/runtime/equal.md +30 -1
  85. package/runtime/exception.gr +38 -47
  86. package/runtime/exception.md +10 -8
  87. package/runtime/gc.gr +23 -152
  88. package/runtime/gc.md +13 -17
  89. package/runtime/malloc.gr +31 -31
  90. package/runtime/malloc.md +11 -3
  91. package/runtime/numberUtils.gr +193 -174
  92. package/runtime/numberUtils.md +29 -9
  93. package/runtime/numbers.gr +1695 -1021
  94. package/runtime/numbers.md +1098 -134
  95. package/runtime/string.gr +543 -245
  96. package/runtime/string.md +76 -6
  97. package/runtime/unsafe/constants.gr +30 -13
  98. package/runtime/unsafe/constants.md +80 -0
  99. package/runtime/unsafe/conv.gr +55 -28
  100. package/runtime/unsafe/conv.md +41 -9
  101. package/runtime/unsafe/memory.gr +10 -30
  102. package/runtime/unsafe/memory.md +15 -19
  103. package/runtime/unsafe/tags.gr +37 -21
  104. package/runtime/unsafe/tags.md +88 -8
  105. package/runtime/unsafe/wasmf32.gr +30 -36
  106. package/runtime/unsafe/wasmf32.md +64 -56
  107. package/runtime/unsafe/wasmf64.gr +30 -36
  108. package/runtime/unsafe/wasmf64.md +64 -56
  109. package/runtime/unsafe/wasmi32.gr +49 -66
  110. package/runtime/unsafe/wasmi32.md +102 -94
  111. package/runtime/unsafe/wasmi64.gr +52 -79
  112. package/runtime/unsafe/wasmi64.md +108 -100
  113. package/runtime/utils/printing.gr +13 -15
  114. package/runtime/utils/printing.md +11 -3
  115. package/runtime/wasi.gr +294 -295
  116. package/runtime/wasi.md +62 -42
  117. package/set.gr +574 -64
  118. package/set.md +634 -54
  119. package/stack.gr +181 -64
  120. package/stack.md +271 -42
  121. package/string.gr +453 -533
  122. package/string.md +241 -151
  123. package/uint16.gr +369 -0
  124. package/uint16.md +585 -0
  125. package/uint32.gr +470 -0
  126. package/uint32.md +737 -0
  127. package/uint64.gr +471 -0
  128. package/uint64.md +737 -0
  129. package/uint8.gr +369 -0
  130. package/uint8.md +585 -0
  131. package/uri.gr +1093 -0
  132. package/uri.md +477 -0
  133. package/{sys → wasi}/file.gr +914 -500
  134. package/{sys → wasi}/file.md +454 -50
  135. package/wasi/process.gr +292 -0
  136. package/{sys → wasi}/process.md +164 -6
  137. package/wasi/random.gr +77 -0
  138. package/wasi/random.md +80 -0
  139. package/{sys → wasi}/time.gr +15 -22
  140. package/{sys → wasi}/time.md +5 -5
  141. package/immutablearray.gr +0 -929
  142. package/immutablearray.md +0 -1038
  143. package/immutablemap.gr +0 -493
  144. package/immutablemap.md +0 -479
  145. package/immutablepriorityqueue.gr +0 -360
  146. package/immutablepriorityqueue.md +0 -291
  147. package/immutableset.gr +0 -498
  148. package/immutableset.md +0 -449
  149. package/runtime/debug.gr +0 -2
  150. package/runtime/debug.md +0 -6
  151. package/runtime/unsafe/errors.gr +0 -36
  152. package/runtime/unsafe/errors.md +0 -204
  153. package/sys/process.gr +0 -254
  154. package/sys/random.gr +0 -79
  155. package/sys/random.md +0 -66
package/json.md ADDED
@@ -0,0 +1,646 @@
1
+ ---
2
+ title: Json
3
+ ---
4
+
5
+ JSON (JavaScript Object Notation) parsing, printing, and access utilities.
6
+
7
+ ```grain
8
+ from "json" include Json
9
+ ```
10
+
11
+ ```grain
12
+ Json.parse("{\"currency\":\"€\",\"price\":99.99}")
13
+ ```
14
+
15
+ ```grain
16
+ print(
17
+ toString(
18
+ format=Pretty,
19
+ JsonObject([("currency", JsonString("€")), ("price", JsonNumber(99.9))])
20
+ )
21
+ )
22
+ ```
23
+
24
+ ## Types
25
+
26
+ Type declarations included in the Json module.
27
+
28
+ ### Json.**Json**
29
+
30
+ ```grain
31
+ enum Json {
32
+ JsonNull,
33
+ JsonBoolean(Bool),
34
+ JsonNumber(Number),
35
+ JsonString(String),
36
+ JsonArray(List<Json>),
37
+ JsonObject(List<(String, Json)>),
38
+ }
39
+ ```
40
+
41
+ Data structure representing JSON in Grain.
42
+
43
+ Variants:
44
+
45
+ ```grain
46
+ JsonNull
47
+ ```
48
+
49
+ Represents the JSON `null` value.
50
+
51
+ ```grain
52
+ JsonBoolean(Bool)
53
+ ```
54
+
55
+ Represents a JSON boolean value.
56
+
57
+ ```grain
58
+ JsonNumber(Number)
59
+ ```
60
+
61
+ Represents a JSON number value.
62
+
63
+ ```grain
64
+ JsonString(String)
65
+ ```
66
+
67
+ Represents a JSON string value.
68
+
69
+ ```grain
70
+ JsonArray(List<Json>)
71
+ ```
72
+
73
+ Represents a JSON array value.
74
+
75
+ ```grain
76
+ JsonObject(List<(String, Json)>)
77
+ ```
78
+
79
+ Represents a JSON object value, as a list of (key, value).
80
+
81
+ Examples:
82
+
83
+ ```grain
84
+ assert Json.parse("{\"currency\":\"€\",\"price\":99.99}") == JsonObject([
85
+ ("currency", JsonString("€")),
86
+ ("price", JsonNumber(99.99)),
87
+ ])
88
+ ```
89
+
90
+ ```grain
91
+ assert Json.parse("{\n\"currency\":\"€\",\n\"price\":99.99\n}") == JsonObject([
92
+ ("currency", JsonString("€")),
93
+ ("price", JsonNumber(99.99)),
94
+ ])
95
+ ```
96
+
97
+ ### Json.**JsonToStringError**
98
+
99
+ ```grain
100
+ enum JsonToStringError {
101
+ InvalidNumber(String),
102
+ }
103
+ ```
104
+
105
+ Represents errors for cases where a `Json` data structure cannot be represented as a
106
+ JSON string.
107
+
108
+ Variants:
109
+
110
+ ```grain
111
+ InvalidNumber(String)
112
+ ```
113
+
114
+ The `Json` data structure contains a number value of `NaN`, `Infinity`, or `-Infinity`.
115
+
116
+ ### Json.**IndentationFormat**
117
+
118
+ ```grain
119
+ enum IndentationFormat {
120
+ NoIndentation,
121
+ IndentWithTab,
122
+ IndentWithSpaces(Number),
123
+ }
124
+ ```
125
+
126
+ Controls how indentation is output in custom formatting.
127
+
128
+ Variants:
129
+
130
+ ```grain
131
+ NoIndentation
132
+ ```
133
+
134
+ No indentation is emitted.
135
+
136
+ ```json
137
+ {
138
+ "currency": "€",
139
+ "price": 99.9
140
+ }
141
+ ```
142
+
143
+ ```grain
144
+ IndentWithTab
145
+ ```
146
+
147
+ Tabs are emitted.
148
+
149
+ ```json
150
+ {
151
+ "currency": "€",
152
+ "price": 99.9
153
+ }
154
+ ```
155
+
156
+ ```grain
157
+ IndentWithSpaces(Number)
158
+ ```
159
+
160
+ The desired number of spaces are emitted.
161
+
162
+ `IndentWithSpaces(2)`
163
+ ```json
164
+ {
165
+ "currency": "€",
166
+ "price": 99.9
167
+ }
168
+ ```
169
+
170
+ `IndentWithSpaces(4)`
171
+ ```json
172
+ {
173
+ "currency": "€",
174
+ "price": 99.9
175
+ }
176
+ ```
177
+
178
+ ### Json.**ArrayFormat**
179
+
180
+ ```grain
181
+ enum ArrayFormat {
182
+ CompactArrayEntries,
183
+ SpacedArrayEntries,
184
+ OneArrayEntryPerLine,
185
+ }
186
+ ```
187
+
188
+ Controls how arrays are output in custom formatting.
189
+
190
+ Variants:
191
+
192
+ ```grain
193
+ CompactArrayEntries
194
+ ```
195
+
196
+ Arrays are emitted in a compact manner.
197
+
198
+ ```json
199
+ []
200
+ ```
201
+
202
+ ```json
203
+ [1]
204
+ ```
205
+
206
+ ```json
207
+ [1,2,3]
208
+ ```
209
+
210
+ ```grain
211
+ SpacedArrayEntries
212
+ ```
213
+
214
+ Arrays are emitted with spaces between elements.
215
+
216
+ ```json
217
+ [ ]
218
+ ```
219
+
220
+ ```json
221
+ [1]
222
+ ```
223
+
224
+ ```json
225
+ [1, 2, 3]
226
+ ```
227
+
228
+ ```grain
229
+ OneArrayEntryPerLine
230
+ ```
231
+
232
+ Arrays are emitted with newlines and indentation between each element.
233
+
234
+ ```json
235
+ []
236
+ ```
237
+
238
+ ```json
239
+ [
240
+ 1
241
+ ]
242
+ ```
243
+
244
+ ```json
245
+ [
246
+ 1,
247
+ 2,
248
+ 3
249
+ ]
250
+ ```
251
+
252
+ ### Json.**ObjectFormat**
253
+
254
+ ```grain
255
+ enum ObjectFormat {
256
+ CompactObjectEntries,
257
+ SpacedObjectEntries,
258
+ OneObjectEntryPerLine,
259
+ }
260
+ ```
261
+
262
+ Controls how objects are output in custom formatting.
263
+
264
+ Variants:
265
+
266
+ ```grain
267
+ CompactObjectEntries
268
+ ```
269
+
270
+ Objects are emitted in a compact manner.
271
+
272
+ ```json
273
+ {}
274
+ ```
275
+
276
+ ```json
277
+ {"a":1}
278
+ ```
279
+
280
+ ```json
281
+ {"a":1,"b":2,"c":3}
282
+ ```
283
+
284
+ ```grain
285
+ SpacedObjectEntries
286
+ ```
287
+
288
+ Objects are emitted with spaces between entries.
289
+
290
+ ```json
291
+ { }
292
+ ```
293
+
294
+ ```json
295
+ {"a": 1}
296
+ ```
297
+
298
+ ```json
299
+ {"a": 1, "b": 2, "c": 3}
300
+ ```
301
+
302
+ ```grain
303
+ OneObjectEntryPerLine
304
+ ```
305
+
306
+ Objects are emitted with each entry on a new line.
307
+
308
+ ```
309
+ {}
310
+ ```
311
+
312
+ ```
313
+ {
314
+ "a": 1
315
+ }
316
+ ```
317
+
318
+ ```
319
+ {
320
+ "a": 1,
321
+ "b": 2,
322
+ "c": 3
323
+ }
324
+ ```
325
+
326
+ ### Json.**LineEnding**
327
+
328
+ ```grain
329
+ enum LineEnding {
330
+ NoLineEnding,
331
+ LineFeed,
332
+ CarriageReturnLineFeed,
333
+ CarriageReturn,
334
+ }
335
+ ```
336
+
337
+ Controls how line endings are output in custom formatting.
338
+
339
+ Variants:
340
+
341
+ ```grain
342
+ NoLineEnding
343
+ ```
344
+
345
+ No line endings will be emitted.
346
+
347
+ ```grain
348
+ LineFeed
349
+ ```
350
+
351
+ A `\n` will be emitted at the end of each line.
352
+
353
+ ```grain
354
+ CarriageReturnLineFeed
355
+ ```
356
+
357
+ A `\r\n` will be emitted at the end of each line.
358
+
359
+ ```grain
360
+ CarriageReturn
361
+ ```
362
+
363
+ A `\r` will be emitted at the end of each line.
364
+
365
+ ### Json.**FormattingChoices**
366
+
367
+ ```grain
368
+ enum FormattingChoices {
369
+ Pretty,
370
+ Compact,
371
+ PrettyAndSafe,
372
+ CompactAndSafe,
373
+ Custom{
374
+ indentation: IndentationFormat,
375
+ arrayFormat: ArrayFormat,
376
+ objectFormat: ObjectFormat,
377
+ lineEnding: LineEnding,
378
+ finishWithNewLine: Bool,
379
+ escapeAllControlPoints: Bool,
380
+ escapeHTMLUnsafeSequences: Bool,
381
+ escapeNonASCII: Bool,
382
+ },
383
+ }
384
+ ```
385
+
386
+ Allows control of formatting in JSON output.
387
+
388
+ Variants:
389
+
390
+ ```grain
391
+ Pretty
392
+ ```
393
+
394
+ Recommended human readable formatting.
395
+
396
+ Escapes all control points for the sake of clarity, but outputs unicode
397
+ codepoints directly so the result needs to be treated as proper unicode and
398
+ is not safe to be transported in ASCII encoding.
399
+
400
+ Roughly Equivalent to:
401
+ ```grain
402
+ Custom{
403
+ indentation: IndentWithSpaces(2),
404
+ arrayFormat: OneArrayEntryPerLine,
405
+ objectFormat: OneObjectEntryPerLine,
406
+ lineEnding: LineFeed,
407
+ finishWithNewLine: true,
408
+ escapeAllControlPoints: true,
409
+ escapeHTMLUnsafeSequences: false,
410
+ escapeNonASCII: false,
411
+ }
412
+ ```
413
+
414
+ ```json
415
+ {
416
+ "currency": "€",
417
+ "price": 99.9,
418
+ "currencyDescription": "EURO\u007f",
419
+ }
420
+ ```
421
+
422
+ ```grain
423
+ Compact
424
+ ```
425
+
426
+ Compact formatting that minimizes the size of resulting JSON at cost of not
427
+ being easily human readable.
428
+
429
+ Only performs minimal string escaping as required by the ECMA-404 standard,
430
+ so the result needs to be treated as proper unicode and is not safe to be
431
+ transported in ASCII encoding.
432
+
433
+ Roughly Equivalent to:
434
+ ```grain
435
+ Custom{
436
+ indentation: NoIndentation,
437
+ arrayFormat: CompactArrayEntries,
438
+ objectFormat: CompactObjectEntries,
439
+ lineEnding: NoLineEnding,
440
+ finishWithNewLine: false,
441
+ escapeAllControlPoints: false,
442
+ escapeHTMLUnsafeSequences: false,
443
+ escapeNonASCII: false,
444
+ }
445
+ ```
446
+
447
+ ```json
448
+ {"currency":"€","price":99.9,"currencyDescription":"EURO␡"}
449
+ ```
450
+
451
+ ```grain
452
+ PrettyAndSafe
453
+ ```
454
+
455
+ Pretty and conservative formatting to maximize compatibility and
456
+ embeddability of the resulting JSON.
457
+
458
+ Should be safe to copy and paste directly into HTML and to be transported in
459
+ plain ASCII.
460
+
461
+ Roughly Equivalent to:
462
+ ```grain
463
+ Custom{
464
+ indentation: IndentWithSpaces(2),
465
+ arrayFormat: OneArrayEntryPerLine,
466
+ objectFormat: OneObjectEntryPerLine,
467
+ lineEnding: LineFeed,
468
+ finishWithNewLine: true,
469
+ escapeAllControlPoints: true,
470
+ escapeHTMLUnsafeSequences: true,
471
+ escapeNonASCII: true,
472
+ }
473
+ ```
474
+
475
+ ```json
476
+ {
477
+ "currency": "\u20ac",
478
+ "price": 99.9,
479
+ "currencyDescription": "EURO\u007f",
480
+ }
481
+ ```
482
+
483
+ ```grain
484
+ CompactAndSafe
485
+ ```
486
+
487
+ Compact and conservative formatting to maximize compatibility and
488
+ embeddability of the resulting JSON.
489
+
490
+ Should be safe to copy and paste directly into HTML and to transported in
491
+ plain ASCII.
492
+
493
+ Roughly Equivalent to:
494
+ ```grain
495
+ Custom{
496
+ indentation: NoIndentation,
497
+ arrayFormat: CompactArrayEntries,
498
+ objectFormat: CompactObjectEntries,
499
+ lineEnding: NoLineEnding,
500
+ finishWithNewLine: false,
501
+ escapeAllControlPoints: true,
502
+ escapeHTMLUnsafeSequences: true,
503
+ escapeNonASCII: true,
504
+ }
505
+ ```
506
+
507
+ ```json
508
+ {"currency":"\u20ac","price":99.9,"currencyDescription":"EURO\u007f"}
509
+ ```
510
+
511
+ ```grain
512
+ Custom{
513
+ indentation: IndentationFormat,
514
+ arrayFormat: ArrayFormat,
515
+ objectFormat: ObjectFormat,
516
+ lineEnding: LineEnding,
517
+ finishWithNewLine: Bool,
518
+ escapeAllControlPoints: Bool,
519
+ escapeHTMLUnsafeSequences: Bool,
520
+ escapeNonASCII: Bool,
521
+ }
522
+ ```
523
+
524
+ Allows for fined grained control of the formatting output.
525
+
526
+ ### Json.**JsonParseError**
527
+
528
+ ```grain
529
+ enum JsonParseError {
530
+ UnexpectedEndOfInput(String),
531
+ UnexpectedToken(String),
532
+ InvalidUTF16SurrogatePair(String),
533
+ }
534
+ ```
535
+
536
+ Represents errors for JSON parsing along with a human readable message.
537
+
538
+ ## Values
539
+
540
+ Functions and constants included in the Json module.
541
+
542
+ ### Json.**toString**
543
+
544
+ <details disabled>
545
+ <summary tabindex="-1">Added in <code>0.6.0</code></summary>
546
+ No other changes yet.
547
+ </details>
548
+
549
+ ```grain
550
+ toString :
551
+ (?format: FormattingChoices, json: Json) =>
552
+ Result<String, JsonToStringError>
553
+ ```
554
+
555
+ Converts the `Json` data structure into a JSON string with specific formatting settings.
556
+
557
+ Parameters:
558
+
559
+ |param|type|description|
560
+ |-----|----|-----------|
561
+ |`?format`|`FormattingChoices`|Formatting options|
562
+ |`json`|`Json`|The `Json` data structure to convert|
563
+
564
+ Returns:
565
+
566
+ |type|description|
567
+ |----|-----------|
568
+ |`Result<String, JsonToStringError>`|`Ok(str)` containing the JSON string or `Err(err)` if the provided `Json` data structure cannot be converted to a string|
569
+
570
+ Examples:
571
+
572
+ ```grain
573
+ assert toString(
574
+ JsonObject([("currency", JsonString("€")), ("price", JsonNumber(99.9))]
575
+ ) == Ok("{\"currency\":\"€\",\"price\":99.9}")
576
+ ```
577
+
578
+ ```grain
579
+ assert toString(
580
+ format=Compact
581
+ JsonObject([("currency", JsonString("€")), ("price", JsonNumber(99.9))])
582
+ ) == Ok("{\"currency\":\"€\",\"price\":99.9}")
583
+ ```
584
+
585
+ ```grain
586
+ assert toString(
587
+ format=Pretty,
588
+ JsonObject([("currency", JsonString("€")), ("price", JsonNumber(99.9))])
589
+ ) == Ok("{
590
+ \"currency\": \"€\",
591
+ \"price\": 99.9
592
+ }")
593
+ ```
594
+
595
+ ```grain
596
+ assert toString(
597
+ format=Custom{
598
+ indentation: NoIndentation,
599
+ arrayFormat: CompactArrayEntries,
600
+ objectFormat: CompactObjectEntries,
601
+ lineEnding: NoLineEnding,
602
+ finishWithNewLine: false,
603
+ escapeAllControlPoints: true,
604
+ escapeHTMLUnsafeSequences: true,
605
+ escapeNonASCII: true,
606
+ },
607
+ JsonObject([("currency", JsonString("€")), ("price", JsonNumber(99.9))])
608
+ ) == Ok("{\"currency\":\"\\u20ac\",\"price\":99.9}")
609
+ ```
610
+
611
+ ### Json.**parse**
612
+
613
+ <details disabled>
614
+ <summary tabindex="-1">Added in <code>0.6.0</code></summary>
615
+ No other changes yet.
616
+ </details>
617
+
618
+ ```grain
619
+ parse : (str: String) => Result<Json, JsonParseError>
620
+ ```
621
+
622
+ Parses JSON string into a `Json` data structure.
623
+
624
+ Parameters:
625
+
626
+ |param|type|description|
627
+ |-----|----|-----------|
628
+ |`str`|`String`|The JSON string to parse|
629
+
630
+ Returns:
631
+
632
+ |type|description|
633
+ |----|-----------|
634
+ |`Result<Json, JsonParseError>`|`Ok(json)` containing the parsed data structure on a successful parse or `Err(err)` containing a parse error otherwise|
635
+
636
+ Examples:
637
+
638
+ ```grain
639
+ assert parse("{\"currency\":\"$\",\"price\":119}") == Ok(
640
+ JsonObject([
641
+ ("currency", JsonString("$")),
642
+ ("price", JsonNumber(119))
643
+ ])
644
+ )
645
+ ```
646
+