Closed zzzzwc closed 1 year ago
The comma should cause an error to be returned. I'll debug it this evening.
What is happening is that parsing is reading the valid JSON of 1
but not giving an error on the comma and continues parsing which it should not do. In the second case you can see that the parser continues and errors on the a
but would probably be okay with "a"
which is a valid json.
Please try the no-comma-error branch.
It fixed: the code
func TestOjgParse(t *testing.T) {
v, err := oj.ParseString("1,2,3\n")
fmt.Println(v)
fmt.Println(err)
fmt.Println("----------")
v, err = oj.ParseString("1,2,a\n")
fmt.Println(v)
fmt.Println(err)
}
outputs
=== RUN TestOjgParse
<nil>
unexpected comma at 1:2
----------
<nil>
unexpected comma at 1:2
--- PASS: TestOjgParse (0.00s)
PASS
as expected. Thank you!
There may be a bug of oj.ParseString:
It outputs:
the string '1,2,3\n' isn't to be a JSON either, but ParseString didn't return an error.