Skip to content

Failing to parse 0 as long value when using the any api with streaming support #301

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

Closed
haferjir opened this issue Aug 16, 2021 · 1 comment · Fixed by #243
Closed

Failing to parse 0 as long value when using the any api with streaming support #301

haferjir opened this issue Aug 16, 2021 · 1 comment · Fixed by #243

Comments

@haferjir
Copy link

I'm trying to use Jsoniter (v0.9.23) in streaming mode, but our regression suite found an issue, when parsing a json object containing a 0.

Example:

import static org.junit.Assert.assertEquals;

import org.junit.Test;

import com.jsoniter.JsonIterator;
import com.jsoniter.any.Any;

public class JsonIteratorStreamingNotWorkingOnZeroTest {
    @Test
    public void minimalExampleWithStreaming() {
        JsonIterator.enableStreamingSupport();
        String json = "{\"a\":0}";
        Any any = JsonIterator.deserialize(json);
        assertEquals(0, any.get("a").toInt()); // Throws JsonException
    }
}

The code above should describe a successful test but fails with a JsonException inside IterImplForStreaming::readByte. That is because it tries to read the next byte after the zero and assert that there isn't any numbers after the 0. But the any api only provides the JsonIterator that contains the 0 and reading the next byte will fail.

@svobol13
Copy link
Collaborator

This bug was fixed within #243 . Thanks for reporting @haferjir !

@svobol13 svobol13 linked a pull request Jan 23, 2022 that will close this issue
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 a pull request may close this issue.

2 participants