Conversation
…limit #3 - okj_get_array() and okj_get_object() now return an accurate count field by walking the raw JSON text rather than returning 0U unconditionally. Added three static helpers in ok_json.c: - okj_skip_string(): advances past a quoted JSON string - okj_count_array_elements(): counts comma-delimited elements at depth 1, skipping nested arrays/objects and string content - okj_count_object_members(): counts colons at depth 1 (one per member), skipping nested structures and string content #4 - The string scan loop in okj_parse_value() now breaks when the running length reaches OKJ_MAX_STRING_LEN and returns OKJ_ERROR_MAX_STR_LEN_EXCEEDED instead of scanning unbounded input. Also changed okj_parse() to propagate the specific error code from okj_parse_value() rather than always returning OKJ_ERROR_PARSING_FAILED, which lets callers distinguish error causes without digging into internals. Three new tests added (16 total, all passing): - test_get_array_count: verifies count == 3 for a three-element array - test_get_object_count: verifies count == 2 for a two-member nested object - test_string_too_long: verifies OKJ_ERROR_MAX_STR_LEN_EXCEEDED for a 65-character value string (one over the 64-byte limit) https://claude.ai/code/session_01TFz4uUuUb77evcWUexuxGv
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
…limit
#3 - okj_get_array() and okj_get_object() now return an accurate count field by walking the raw JSON text rather than returning 0U unconditionally. Added three static helpers in ok_json.c:
#4 - The string scan loop in okj_parse_value() now breaks when the running length reaches OKJ_MAX_STRING_LEN and returns OKJ_ERROR_MAX_STR_LEN_EXCEEDED instead of scanning unbounded input.
Also changed okj_parse() to propagate the specific error code from okj_parse_value() rather than always returning OKJ_ERROR_PARSING_FAILED, which lets callers distinguish error causes without digging into internals.
Three new tests added (16 total, all passing):
https://claude.ai/code/session_01TFz4uUuUb77evcWUexuxGv