Forum Discussion
richie
Community Hero
Hey harishlean,
Just trying to understand.
When you say the json is invalid, do you mean 'malformed' or 'invalid'?
Malformed means that the json payload does not conform to standard syntactical wellformed json rules.
Invalid means that the json payload is invalid relative to either a json schema/swagger/open api definition.
Im asking to clarify cos they mean two different things and they need different resolutions to sort.
Are you saying you get a response back, but the json payload is actually malformed json?
To confirm if its malformed json, copy the payload into here -->
https://jsonpathfinder.com/
If the jsonpathfinder website errors, then you have malformed json.
If the payload is malformed json, then you need a code fix to sort as your endpoint youre hitting should NOT be returning malformed json.
ReadyAPI/SoapUI uses a json parser to read and recognise the json payload allowing you to assert or grab a value as a property, but the parser will only be able to read wellformed json. It wont work if its malformed.
Depending on how badly malformed the json is, you can use an event handler to alter the response payload to make it wellformed, but it's a little complicated and depends on how malformed the json payload is.
If you can publish the json payload so we can see it, we might be able to resolve to allow you to continue working, HOWEVER, your developers will still need to fix the json to make it wellformed anyway, cos this is definitely a defect.
Cheers,
Rich
Just trying to understand.
When you say the json is invalid, do you mean 'malformed' or 'invalid'?
Malformed means that the json payload does not conform to standard syntactical wellformed json rules.
Invalid means that the json payload is invalid relative to either a json schema/swagger/open api definition.
Im asking to clarify cos they mean two different things and they need different resolutions to sort.
Are you saying you get a response back, but the json payload is actually malformed json?
To confirm if its malformed json, copy the payload into here -->
https://jsonpathfinder.com/
If the jsonpathfinder website errors, then you have malformed json.
If the payload is malformed json, then you need a code fix to sort as your endpoint youre hitting should NOT be returning malformed json.
ReadyAPI/SoapUI uses a json parser to read and recognise the json payload allowing you to assert or grab a value as a property, but the parser will only be able to read wellformed json. It wont work if its malformed.
Depending on how badly malformed the json is, you can use an event handler to alter the response payload to make it wellformed, but it's a little complicated and depends on how malformed the json payload is.
If you can publish the json payload so we can see it, we might be able to resolve to allow you to continue working, HOWEVER, your developers will still need to fix the json to make it wellformed anyway, cos this is definitely a defect.
Cheers,
Rich
harishlean
4 years agoNew Contributor
Hi Riche,
Thank You for the reply. I have provided a sample response below.
{
"product":"book",
"product":"book",
"title":"atomic habits"
}
Since the attribute "product" is repeated twice, I am getting the mentioned error. It would be great if it can be handled via event handler. I just want to capture the value of "title"
Get Outlook for Android
Thank You for the reply. I have provided a sample response below.
{
"product":"book",
"product":"book",
"title":"atomic habits"
}
Since the attribute "product" is repeated twice, I am getting the mentioned error. It would be great if it can be handled via event handler. I just want to capture the value of "title"
Get Outlook for Android
- nmrao4 years agoChampion Level 3You need to first check with your development team or service provider and let them address the issue.
- richie4 years agoCommunity Hero
Hey harishlean
ok - so your json is actually malformed. This is definitely a defect and as nmrao said, you will need raising with your developers.
As I said previously - it is possible to alter your response before you get the chance to assert/property transfer using an event handler, but due to the fact you have a duplicate, you cant use jsonpath to identify and remove the erroneous info and so this is beyond my groovy skills - I only know the basic stuff that Rao's taught me!
One of the groovy experts on here might be able to help - but I kinda think you'd be wasting your time as the payload is defective.
Makes more sense to get the payload fixed first.
Cheers,
Rich
- sonya_m4 years agoSmartBear Alumni (Retired)
Related Content
- 2 years ago
- 6 years ago
Recent Discussions
- 19 hours ago
- 17 days ago