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

Unconsumed '}' in (*traverser).decodeObject() causes entries loss after nested empty object #653

Closed
zhongxinghong opened this issue Jun 18, 2024 · 0 comments

Comments

@zhongxinghong
Copy link
Contributor

The #630 lost self.parser.p++ for empty object in (*traverser).decodeObject(). The TwitterJSON doesn't contain pattern like {..., "k": {}, ...} so this problem was not detected by unit tests.

Test case: {"v0": 0, "m0": {}, "v1": 1, "a0": [], "v2": 2}
Output:

=== RUN   TestVisitor_NodeDiff/issue_case02
    visitor_test.go:243: 
                Error Trace:    /Users/bytedance/go/src/github.com/bytedance/sonic/ast/visitor_test.go:243
                                                        /Users/bytedance/go/src/github.com/bytedance/sonic/ast/visitor.go:304
                                                        /Users/bytedance/go/src/github.com/bytedance/sonic/ast/visitor.go:167
                                                        /Users/bytedance/go/src/github.com/bytedance/sonic/ast/visitor.go:132
                                                        /Users/bytedance/go/src/github.com/bytedance/sonic/ast/visitor_test.go:318
                                                        /Users/bytedance/go/src/github.com/bytedance/sonic/ast/visitor_test.go:342
                Error:          Not equal: 
                                expected: []string{"a0", "m0", "v0", "v1", "v2"}
                                actual  : []string{"m0", "v0"}
                            
                                Diff:
                                --- Expected
                                +++ Actual
                                @@ -1,7 +1,4 @@
                                -([]string) (len=5) {
                                - (string) (len=2) "a0",
                                +([]string) (len=2) {
                                  (string) (len=2) "m0",
                                - (string) (len=2) "v0",
                                - (string) (len=2) "v1",
                                - (string) (len=2) "v2"
                                + (string) (len=2) "v0"
                                 }
                Test:           TestVisitor_NodeDiff/issue_case02
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

No branches or pull requests

2 participants