-
Notifications
You must be signed in to change notification settings - Fork 2
serializers
In particular: JsonCppSerializer && JsonCppDeserializer
NOTE: AI assisted information
To evaluate your custom JSON parser's feature parity, you must test it against edge cases, strict RFC standards, and performance limits. [1] The industry standard for this is the JSONTestSuite, which exposes common parser vulnerabilities, compliance gaps, and crashes.
Do not write your own edge cases from scratch. Use established, comprehensive test matrices:
- JSONTestSuite: Use the [nst/JSONTestSuite GitHub repository](https://github.com/nst/JSONTestSuite). It contains over 300 test files categorized into y_ (should accept), n_ (should reject), and i_ (implementation-defined behavior).
- JSON Checker: Use the original JSON_checker.c test suite from JSON.org to verify basic structural pass/fail boundaries.
Your parser should handle the official RFC 8259 and ECMA-404 specifications. Verify your code against these major functional areas: [2, 3, 4]
- Data Types & Literals:
- Strict case sensitivity for true, false, and null (reject True or NULL).
- Empty structural elements like empty objects {} and empty arrays []. [5, 6, 7]
- Number Precision & Formats:
- Negative numbers (-1), fractions (0.5), and exponents (1e10, 1E-5).
- Rejection of leading zeros (0123), hex formats (0x1A), or dangling decimals (1.).
- Handling of large integers and floating-point precision limits. [8, 9]
- String Escaping:
- Standard control codes: ", \, /, \b, \f, \n, \r, \t.
- Unicode hex escapes: \uXXXX (e.g., \u0020).
- Surrogate pairs for emojis and extended characters (e.g., \uD83D\uDCA9). [10]
- Structural Strictness:
- Trailing commas in objects {"a": 1,} and arrays [1, 2,] (should fail in strict mode).
- Duplicate keys {"a": 1, "a": 2} (RFC allows this, but your parser must handle it predictably, usually keeping the last value). [11, 12, 13]
A production-ready parser must fail gracefully instead of crashing your runtime environment:
- Deep Nesting (Stack Overflow): Test an array nested 10,000 layers deep ([[...]]). Your parser should safely reject it or throw a controlled nesting-depth error rather than crashing the call stack.
- Whitespace Handling: Ensure your parser correctly skips all valid structural whitespaces: space (0x20), horizontal tab (0x09), line feed (0x0A), and carriage return (0x0D). [14]
- Improperly Terminated Data: Pass truncated JSON strings like {"name": "John or [1, 2, to ensure your parser throws a clean syntax exception.
To help you build a matching test harness, could you tell me:
- What language did you write your custom parser in?
- Do you want to support non-standard features like comments (//) or trailing commas, or stick strictly to RFC 8259?
I can provide a automated script or a list of specific test payloads tailored to your setup.
[1] [https://metacpan.org](https://metacpan.org/release/BKB/JSON-Parse-0.29_02/view/lib/JSON/Parse.pod) [2] [https://www.learnjsonschema.com](https://www.learnjsonschema.com/2020-12/validation/type/) [3] [https://docs.groovy-lang.org](https://docs.groovy-lang.org/next/html/documentation/json-userguide.html) [4] [https://metacpan.org](https://metacpan.org/dist/JSON-Parse/view/lib/JSON/Parse.pod) [5] [https://medium.com](https://medium.com/towardsdev/a-complete-guide-to-work-with-json-in-snowflake-31272add6a74) [6] [https://www.sitepoint.com](https://www.sitepoint.com/json-validator/) [7] [https://www.capesoft.com](https://www.capesoft.com/docs/jfiles3/jfiles.htm) [8] [https://filemakerhacks.com](https://filemakerhacks.com/2023/03/31/json-force-standard-notation/) [9] [https://inventivehq.com](https://inventivehq.com/blog/common-json-validation-errors-and-how-to-fix-them) [10] [https://blog.liquid-technologies.com](https://blog.liquid-technologies.com/json-best-practices-and-conventions-part-2-of-4) [11] [https://digitalheroesco.com](https://digitalheroesco.com/tools/json-formatter/) [12] [https://theproductguy.in](https://theproductguy.in/blogs/json-syntax-error-fix/) [13] [https://www.simular.ai](https://www.simular.ai/workflow/how-to-parse-json-in-snowflake-a-practical-guide-for-teams) [14] [https://theproductguy.in](https://theproductguy.in/blogs/json-indent-guide/)
Consider pulling in part of the JSONTestSuite1000 git repo via cmake's
FetchContent or similar (~100MB+ uncompressed)
- over 300 test files categorized into
-
y_(should accept), -
n_(should reject), -
i_(implementation-defined behavior)
-
Deep Nesting