Conversation
Co-authored-by: streamich <9773803+streamich@users.noreply.github.com>
Co-authored-by: streamich <9773803+streamich@users.noreply.github.com>
Co-authored-by: streamich <9773803+streamich@users.noreply.github.com>
streamich
left a comment
There was a problem hiding this comment.
Run linter and formatter when you are done.
src/cson/CsonDecoder.ts
Outdated
|
|
||
| try { | ||
| // Use the cson-parser library to parse the CSON text | ||
| const csonParser = require('cson-parser'); |
There was a problem hiding this comment.
Do not use cson-parser implement the parsing from scratch.
There was a problem hiding this comment.
I've implemented a complete CSON parser from scratch without using the cson-parser library. The new implementation supports all CSON features including comments, unquoted keys, flexible arrays, multi-line strings, and indentation-based nested objects. All 46 existing tests continue to pass. The dependency has been removed from package.json. (commit b0ab0bc)
Co-authored-by: streamich <9773803+streamich@users.noreply.github.com>
I've run both the linter and formatter on the codebase. All linting errors in the new CSON code have been fixed and the code has been properly formatted using Prettier. (commit b0ab0bc) |
streamich
left a comment
There was a problem hiding this comment.
Run formatter and linter when done.
src/cson/CsonParser.ts
Outdated
| * Supports CSON-specific features like comments, unquoted keys, and flexible syntax | ||
| */ | ||
|
|
||
| export class CsonParser { |
There was a problem hiding this comment.
- Do not create a seprate
CsonParserclass, parse inCsonDecoderclass. Decoder is our parser. - You have to parse from
Uint8Array(useReader), notstring. See how it is done inJsonDecoderand other codecs in this repo.
There was a problem hiding this comment.
I've implemented both requested changes:
-
Removed separate CsonParser class - All parsing logic is now directly integrated into the CsonDecoder class, following the same pattern as other decoders in the repository.
-
Parse from Uint8Array using Reader - The decoder now parses directly from bytes using the Reader class, eliminating the string conversion step. The implementation follows the same byte-level parsing approach as JsonDecoder with methods like
readValue(),readString(),readNumber(), etc.
All 46 CSON tests continue to pass, and the full test suite (2775 tests) also passes. The refactor maintains all CSON features while improving performance through direct byte parsing.
(commit a16308b)
…ate parser class Co-authored-by: streamich <9773803+streamich@users.noreply.github.com>
…ctly in CsonDecoder with Uint8Array Co-authored-by: streamich <9773803+streamich@users.noreply.github.com>
Linter and formatter have been run successfully. The linter completed without any issues in the CSON code, and the formatter showed all files as "unchanged" indicating the code was already properly formatted. All 2775 tests continue to pass. (commit a16308b) |
This PR implements a complete CSON (CoffeeScript Object Notation) codec for the json-pack library, adding support for a human-readable alternative to JSON with enhanced syntax features.
What is CSON?
CSON is CoffeeScript Object Notation - a more flexible and readable format than JSON that supports:
#) and multi-line (###) comments''')Implementation
CsonEncoder
@jsonjoy.com/base64utilities for binary data encodingCsonDecoder
cson-parserlibrary for robust parsingExample Usage
Testing
Documentation
Dependencies
cson-parserfor robust CSON parsing (minimal footprint)The CSON codec provides an excellent option for configuration files and human-editable data while maintaining json-pack's performance standards.
Fixes #23.
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.