Bug 62397 - JSON Path tester and comma in response interpretation
Summary: JSON Path tester and comma in response interpretation
Status: RESOLVED FIXED
Alias: None
Product: JMeter - Now in Github
Classification: Unclassified
Component: HTTP (show other bugs)
Version: 4.0
Hardware: PC All
: P2 normal (vote)
Target Milestone: JMETER_5.0
Assignee: JMeter issues mailing list
URL:
Keywords: FixedInTrunk
Depends on:
Blocks:
 
Reported: 2018-05-22 12:22 UTC by lars.vogelaar
Modified: 2018-09-05 15:35 UTC (History)
1 user (show)



Attachments
screenshot (14.77 KB, image/png)
2018-05-22 12:22 UTC, lars.vogelaar
Details
Use real JSON parser to pretty print JSON (9.13 KB, patch)
2018-05-25 13:44 UTC, Felix Schumacher
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description lars.vogelaar 2018-05-22 12:22:40 UTC
Created attachment 35943 [details]
screenshot

For the response of a request of recipes, i found the following difference between Text response and JSON Path response:

Response as Text:

"seoMetadescription": "Winters toetje van warm banaan met chocolade, kaneel en slagroom.",


Response as JSON Path Tester:

"seoMetadescription"
        : "Winters toetje van warm banaan met chocolade, 
        kaneel en slagroom.",

Result[0]=Winters toetje van warm banaan met chocolade, 
        kaneel en slagroom.

Where the JSON Path response provides a faulty json, i suppose due to the comma in the value.

Screenshot added
Comment 1 Felix Schumacher 2018-05-25 08:26:19 UTC
Can you describe in more detail, what you expect and what you got? I can't understand, what your exact problem is.

Is it the inserted newline after the text "chocolade,"?
Comment 2 lars.vogelaar 2018-05-25 08:29:40 UTC
Correct. I would expect:
 
Result[0]=Winters toetje van warm banaan met chocolade, kaneel en slagroom.

The newline causes a faulty JSON string
Comment 3 Felix Schumacher 2018-05-25 13:44:17 UTC
Created attachment 35948 [details]
Use real JSON parser to pretty print JSON

This is a patch, that uses the json-smart libraray, that JMeter already includes and gets rid of the regex-parsing stuff.

The formatted output differs a bit from the old one, but I don't think that this should be considered breaking our API.
Comment 4 Philippe Mouawad 2018-05-27 08:58:52 UTC
+1
Thanks Felix
Comment 5 Felix Schumacher 2018-05-29 19:14:22 UTC
Thanks for the report. Will be fixed in JMeter 4.1.

It would be really nice, if you could test the changes.

Date: Tue May 29 19:12:30 2018
New Revision: 1832473

URL: http://svn.apache.org/viewvc?rev=1832473&view=rev
Log:
Don't break lines at commata when using JSON Path Tester

Use JSON Parser and formatter to pretty print JSON strings.

Bugzilla Id. 62397

Modified:
    jmeter/trunk/src/components/org/apache/jmeter/visualizers/RenderAsJSON.java
    jmeter/trunk/test/src/org/apache/jmeter/visualizers/TestRenderAsJson.java
    jmeter/trunk/xdocs/changes.xml
Comment 6 lars.vogelaar 2018-05-30 06:54:42 UTC
Thanks for the quick response and action to fix it :)
Comment 7 The ASF infrastructure team 2022-09-24 20:38:13 UTC
This issue has been migrated to GitHub: https://github.com/apache/jmeter/issues/4786