Unanswered question

Getting backslashes in JSON node in ResponseBody

So I am sending a POST request to ASMX web services, and in the response body JSON nodes have backslashes "\" is there way to parse it into standard json response?

HTTP/1.1 200 OK
Server: Microsoft-IIS/7.5
X-AspNet-Version: 4.0.30319
Cache-Control: private, max-age=0
Content-Type: application/json; charset=utf-8
Date: Tue, 13 Feb 2018 21:49:17 GMT
Connection: Keep-Alive
Content-Length: 740

"{\"cid\":1,\"model\":\"WT50JB\",\"detail\":\"sdf??\",\"unit\":2,\"time_in\":\"2012-12-11T19:00:00\",\"time_out\":\"2012-12-12T13:00:06.2774691+07:00\",\"time_used_dd\":0.0,\"time_used_hh\":0.0}"

Shahboz S.
Shahboz S.

Shahboz S.

Level
0
56 / 100
points

Answers

It looks like the server returns a content which is encoded as a String between double quotes: "<content>" where content was originally a JSON string, and encoded because between quotes.

So here is your choices:

  • see with the developpers if this format is required or if this is an error and use pure JSON.
  • Use extractors based on RegExp instead JSONPath
  • If JSONPath is required, then you can develop a Data Format Extension that will translate this format into a pure JSON format (See https://www.neotys.com/documents/doc/neoload/latest/en/ht...)

Shahboz S.
Shahboz S.

Shahboz S.

Level
0
56 / 100
points

1.https://www.neotys.com/documents/doc/neoload/latest/en/ht... I followed everything to build a java project for encoder and decoder. But in Eclipse when I debug it says "Failed to connect to remote VM. Connection refused.
Connection refused: connect"

2. Developers said this format is required

3. Any examples on regex? How would I extract cid = 1 for example?

1. This seems a Java development issue where it's hard to help you
2. Ok
3. See the documentation on the Variable Extractor: https://www.neotys.com/documents/doc/neoload/latest/en/ht...

To extract "cid = 1", you can say: starting with \"cid\" then Numeric character 1 or N times, then Ending with ,