Commit 08b9823
committed
Support string prefix parsing
This adds support for parsing json from the prefix of a string. It
does so via two small api additions:
- Deserializer now has the `into_reader` associated function, which
consume the deserializer and returns reader it has been using.
- StrRead and SliceRead now have the `index` associated function,
which reports the byte index of the data which will be read next.
These can be used to parse a single value (or multiple values) from
an input string or buffer, and then recover the next byte position
from the reader. It allows the json parser to be easily integrated
into an outer parser, where the JSON data is sitting inside some
larger non-JSON context.1 parent a15bd09 commit 08b9823
3 files changed
+34
-0
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
60 | 60 | | |
61 | 61 | | |
62 | 62 | | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
63 | 68 | | |
64 | 69 | | |
65 | 70 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
412 | 412 | | |
413 | 413 | | |
414 | 414 | | |
| 415 | + | |
| 416 | + | |
| 417 | + | |
| 418 | + | |
| 419 | + | |
415 | 420 | | |
416 | 421 | | |
417 | 422 | | |
| |||
623 | 628 | | |
624 | 629 | | |
625 | 630 | | |
| 631 | + | |
| 632 | + | |
| 633 | + | |
| 634 | + | |
| 635 | + | |
626 | 636 | | |
627 | 637 | | |
628 | 638 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2407 | 2407 | | |
2408 | 2408 | | |
2409 | 2409 | | |
| 2410 | + | |
| 2411 | + | |
| 2412 | + | |
| 2413 | + | |
| 2414 | + | |
| 2415 | + | |
| 2416 | + | |
| 2417 | + | |
| 2418 | + | |
| 2419 | + | |
| 2420 | + | |
| 2421 | + | |
| 2422 | + | |
| 2423 | + | |
| 2424 | + | |
| 2425 | + | |
| 2426 | + | |
| 2427 | + | |
| 2428 | + | |
0 commit comments