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

Improve error messages coming from invalid JSON parsing #665

Open
RedDevilHat opened this issue Nov 24, 2016 · 3 comments
Open

Improve error messages coming from invalid JSON parsing #665

RedDevilHat opened this issue Nov 24, 2016 · 3 comments
Labels
Epic: CLI reporter Dredd's default reporter

Comments

@RedDevilHat
Copy link

Hello, i try test API and have strange error

my json output

{"id":29,"first_name":"Test","last_name":"Testov","avatar":"","language":{"id":1,"code":"ru","name":"\u0420\u0443\u0441\u0441\u043a\u0438\u0439"},"country":{"id":1,"name":"\u0420\u043e\u0441\u0441\u0438\u044f"},"timezone":{"id":383,"title":"Europe\/Moscow","abbreviation":"MSK","utc_offset":"03:00:00","if_dst":false},"roles":["ROLE_USER"]}

and in formated

{
	"id": 29,
	"first_name": "Test",
	"last_name": "Testov",
	"avatar": "",
	"language": {
		"id": 1,
		"code": "ru",
		"name": "Русский"
	},
	"country": {
		"id": 1,
		"name": "Россия"
	},
	"timezone": {
		"id": 383,
		"title": "Europe/Moscow",
		"abbreviation": "MSK",
		"utc_offset": "03:00:00",
		"if_dst": false
	},
	"roles": [
		"ROLE_USER"
	]
}

My apiary json

{
    "id": 1,
    "first_name": "Иван",
    "last_name": "Иванов",
    "avatar": "http://test.com/bundles/app/static/images/default_users_images/undefined_user4.jpg",
    "language": {
        "code": "ru",
        "name": "Русский"
    },
    "country": {
        "id": 1,
        "name": "Россия",
    },
    "timezone": {
        "title": "US/Samoa",
        "abbreviation": "SST",
        "utc_offset": "-11:00:00",
        "if_dst": false
    },
    "roles": [
        "ROLE_USER",
        "ROLE_ADMIN"
    ]
}

and apiary say me after test

Can't validate. Expected body Content-Type is application/json but body is not a parseable JSON: Parse error on line 12: ...ame": "Россия", }, "timezone": { ----------------------^ Expecting 'STRING', got '}'

what's wrongs?

@w-vi
Copy link
Contributor

w-vi commented Nov 24, 2016

It is a strange sounding error, but actually it is caused by the trailing , at the end of "name": "Россия",in the apiary json. If you try to validate the apiary json in http://jsonlint.com/ you'll get the same error.

Deleting that , solves the problem.

@RedDevilHat
Copy link
Author

I think about this error it is necessary to disclose at the time of validation to the blueprint editor, but thank you

@honzajavorek honzajavorek added Epic: CLI reporter Dredd's default reporter improvement labels Dec 8, 2016
@honzajavorek
Copy link
Contributor

This is basic Dredd functionality - to show differences and issues with JSON. The error does need to be more clear. I hope we can address this somehow once we're improving the CLI output.

@honzajavorek honzajavorek changed the title Json not validate, but valide Improve error messages coming from invalid JSON parsing Mar 27, 2018
@honzajavorek honzajavorek modified the milestone: Improve CLI output Jan 12, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Epic: CLI reporter Dredd's default reporter
Projects
None yet
Development

No branches or pull requests

3 participants