Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Account for nested records #4

Open
wants to merge 10 commits into
base: master
Choose a base branch
from
Open

Conversation

matthijsr
Copy link

Previous RecordParser would successfully parse
INNER_NESTING_LEVEL 1
{ "key": { "key2": 1 } }

But fail on
INNER_NESTING_LEVEL 1
{ "key": { "key2": 1 }, "key3": { "key4": 1 } }

Completely skipping "key3" and anything beyond that.

The issue was that STATE_VALUE would check whether it was still nested:
(high downto 1) of the nesting register was 0
Then switch to STATE_IDLE as soon as it received a '}'.

In effect:

{ <- nesting reg: 01 (not nested)
"key":
{ <- nesting reg: 11 (is nested)
"key2": 1
}  <- nesting reg: 01 (not nested) -> STATE_VALUE ends the entire record
,
"key3": 
{
"key4": 1
}
}

This PR adds a number of tests against this behavior, and fixes the STATE_VALUE transition by also checking whether it is still inside the outer record (nesting reg: 01, otherwise 00).

It's possible nested arrays will produce the same issue in ArrayParser, but I haven't verified that yet.

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