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

JSONObject#similar() fails to consider similar a number with/without trailing zero #589

Closed
cdanger opened this issue Feb 28, 2021 · 6 comments

Comments

@cdanger
Copy link

cdanger commented Feb 28, 2021

Hello,
as confirmed by #134 , numbers 1 and 1.0 should be considered the same in JSON. However, the method JSONObject#similar(Object) does not. Here is a simple test:

final JSONObject jsonWithTrailing0 = new JSONObject("{\"name\": 1.0}");
System.out.println(jsonWithTrailing0.toString()); // {"name":1}
final JSONObject jsonWithoutTrailing0 = new JSONObject("{\"name\": 1}");
Assert.assertTrue("Not the same!", jsonWithTrailing0.similar(jsonWithoutTrailing0)); // AssertionError: Not the same!
@cdanger cdanger changed the title Numbers with/without trailing zero not similar according to JSONObject#similar() JSONObject#similar() fails to consider similar a number with/without trailing Feb 28, 2021
@cdanger cdanger changed the title JSONObject#similar() fails to consider similar a number with/without trailing JSONObject#similar() fails to consider similar a number with/without trailing zero Feb 28, 2021
@stleary
Copy link
Owner

stleary commented Mar 1, 2021

@cdanger Thanks for bringing up this issue. Changing existing behavior is generally not encouraged in this project, but let's see if others have an opinion.

@johnjaylward
Copy link
Contributor

johnjaylward commented Mar 1, 2021

@cdanger can you run against the latest master? I believe this was fixed recently

@johnjaylward
Copy link
Contributor

See #575

@cdanger
Copy link
Author

cdanger commented Mar 1, 2021

Indeed, I had tried with the last release 20201115. And now with the latest master, I confirm it is fixed 👍 .
Looking forward to the next release! Anytime soon I hope :-) Thanks for your help.

@stleary
Copy link
Owner

stleary commented Mar 2, 2021

A release will be scheduled before the end of this week.

cdanger added a commit to authzforce/core that referenced this issue Mar 5, 2021
…e's Request AttributeValues

- Moved XACML/JSON profile tests (conformance, etc.) to module pdp-testutils
- Fixed XacmlJsonUtils.canonicalizeResponse() to work around this issue when comparing JSONObjects: stleary/JSON-java#589
- Changed visibility of default XACML/XML Request preprocessor to public
@stleary
Copy link
Owner

stleary commented Oct 6, 2021

Closed due to issue resolved in release 20210307

@stleary stleary closed this as completed Oct 6, 2021
cdanger added a commit to authzforce/xacml-json-model that referenced this issue Nov 2, 2023
- Removed workaround for stleary/JSON-java#589 after upgrade of org.everity.json.schema dependency
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

3 participants