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

String value equality ignores quotes #178

Closed
pbtura opened this issue Sep 28, 2023 · 1 comment
Closed

String value equality ignores quotes #178

pbtura opened this issue Sep 28, 2023 · 1 comment

Comments

@pbtura
Copy link

pbtura commented Sep 28, 2023

When doing equality assertions, JSONAssert considers quoted an unquoted strings to be equal. So for example assertEquals("abc", ""abc"") would pass. Unquoted strings should either be throw an error for invalid json, or at the very least fail equality when compared against a quoted string.

Example code:

    @Test
    public void testJsonString()
    {
        String expected = "{ \"value\": \"abc\"}";
        String actual = "{\"value\": abc}";
        System.out.println(expected);
        System.out.println(actual);
        //this assertion should fail but it will pass
        JSONAssert.assertEquals( expected, actual, true);
    }
@carterpage
Copy link
Member

This is the behavior of the underlying JSON library and not JSONAssert itself.

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