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

Json Validation does not accept "null" as valid json #731

Closed
saadkalim-earnin opened this issue Feb 19, 2020 · 2 comments
Closed

Json Validation does not accept "null" as valid json #731

saadkalim-earnin opened this issue Feb 19, 2020 · 2 comments
Assignees
Labels

Comments

@saadkalim-earnin
Copy link

saadkalim-earnin commented Feb 19, 2020

Describe the issue
When the json "null" is sent in the request body, an exception is thrown in org.mockserver.matchers.JsonStringMatcher#matches
org.json.JSONException: Unparsable JSON string: null.

This means I am unable to match an expectation when the body is the json "null".

I think the problem is in the JSONAssert library
skyscreamer/JSONassert#83

What you are trying to do
Set up an expectation in mock server with "null" as the body, content type json.
Try to match this expectation by making a request to mock server with "null" as the body. The content type should be json.

MockServer version
5.9.1-SNAPSHOT

To Reproduce
Steps to reproduce the issue:

  1. Set up an expectation in mock server with "null" as the body, content type json.
  2. Try to match this expectation by making a request to mock server with "null" as the body. The content type should be json.
    org.json.JSONException: Unparsable JSON string: null at org.mockserver.matchers.JsonStringMatcher#matches

Expected behaviour
"null" should be allowed as valid json, as discussed here https://stackoverflow.com/questions/8526995/is-null-valid-json-4-bytes-nothing-else.

MockServer Log

2020-02-19 11:45:09  org.mockserver.log.MockServerEventLog  FINE  failed to perform json match

	null

 with

	null

 because

	Unparsable JSON string: null
@saadkalim-earnin saadkalim-earnin changed the title Json Validation does not accept "null Json Validation does not accept "null" as valid json Feb 19, 2020
@jamesdbloom jamesdbloom self-assigned this Feb 21, 2020
jamesdbloom added a commit that referenced this issue Mar 21, 2020
…and remove problematic transitive dependencies
@jamesdbloom
Copy link
Collaborator

This has now been fixed as I have replaced JSONassert with JsonUnit as per #738

@JavierSegoviaCordoba
Copy link

@jamesdbloom is it possible to disable Json validation?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants