Commit 4caaa2c
Add TOON format encoding and decoding functionality (#2)
* Add TOON format encoding and decoding functionality
- Implement StringUtils for string manipulation, including escaping and unescaping.
- Create ValidationShared for key validation and safety checks.
- Introduce ToonDecodeOptions and ToonEncodeOptions for customizable encoding/decoding settings.
- Develop ToonDecoder for parsing TOON format strings into JsonNode objects.
- Implement ToonEncoder for converting data structures into TOON format strings.
- Add ToonFormatException for error handling during parsing and encoding.
- Create unit tests for ToonDecoder and ToonEncoder to ensure functionality and data integrity.
- Remove outdated UnitTest1.cs file.
* Update src/ToonFormat/Constants.cs
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
* Update src/ToonFormat/Internal/Encode/Normalize.cs
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
* Update src/ToonFormat/Internal/Encode/Encoders.cs
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
* Optimize parsing performance and fix potential issues
Optimize the performance of the `ParseDelimitedValues` and `ToParsedLines` methods:
- Reduce memory allocation by using `StringBuilder` and `ReadOnlySpan<char>`.
- Allocate capacity in advance to avoid dynamic resizing.
- Replace string operations with more efficient logic.
Fix the code formatting and logic of `IsArrayHeaderAfterHyphen` and `ParseStringLiteral`:
- Adjust the format of the `return` statement.
- Eliminate redundant code.
New `MapRowValuesToPrimitives` method:
- Supports mapping string arrays to JSON primitive values.
Other minor optimizations:
- Fixed the logic for handling blank lines.
- Replaced some string operations with more efficient implementations.
- Fixed the issue of character encoding in comments, improving code readability.
* Update src/ToonFormat/Internal/Encode/Encoders.cs
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
* Update src/ToonFormat/Internal/Encode/Normalize.cs
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
* Unified logic for negative zero normalization of floating-point numbers, and a new FloatUtils utility class has been added.
Introduce the FloatUtils utility class and provide the NormalizeSignedZero method,
to uniformly handle the logic of negated zero normalization for floating-point numbers, replacing the original repetitive implementations.
Update the relevant code in Parser.cs and Normalize.cs to enhance readability.
Add the NearlyEqual method for approximate comparison of floating-point numbers.
Delete the references to the Internal\Shared\ folder.
---------
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>1 parent 8bf7d83 commit 4caaa2c
File tree
26 files changed
+3672
-65
lines changed- src/ToonFormat
- Internal
- Converters
- Decode
- Encode
- Options
- tests/ToonFormat.Tests
26 files changed
+3672
-65
lines changedThis file was deleted.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
Lines changed: 27 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
Lines changed: 24 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
0 commit comments