Skip to content

Correct the lengths for the "get" shortcut container functions - #474

Open
ridiculousfish wants to merge 1 commit into
simd-lite:mainfrom
ridiculousfish:fix-try-get-containers
Open

Correct the lengths for the "get" shortcut container functions#474
ridiculousfish wants to merge 1 commit into
simd-lite:mainfrom
ridiculousfish:fix-try-get-containers

Conversation

@ridiculousfish

Copy link
Copy Markdown

Containers in simd-json are represented via a header node, followed by the contained nodes. Thus the number of nodes should be one more than the length of the container.

This +1 was correctly applied in "get/try_get" path followed by as_array/as_object, but was missed in the typed shortcut functions such as "get_array" or "try_get_array." Thus "try_get" would return arrays and objects missing their last element; or an invalid object if the array was empty.

Correct this and add a test.

Containers in simd-json are represented via a header node, followed
by the contained nodes. Thus the number of nodes should be one more than
the length of the container.

This +1 was correctly applied in "get/try_get" path followed by
as_array/as_object, but was missed in the typed shortcut functions such as
"get_array" or "try_get_array." Thus "try_get" would return arrays and
objects missing their last element; or an invalid object if the array
was empty.

Correct this and add a test.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant