Argument Extraction using JSON 2.0 differs in 10.x to that of 8.x version

Document ID : KB000075094
Last Modified Date : 30/03/2018
Show Technical Document Details
Issue:
When we tried to parse arguments using JSON Data Protocol the arguments extracted differs in the VSI from  8.x to 10.x
For example:  See Sample Json, 

"name":"John", 
"age":30, 
"cars":[ "Ford", "BMW", "Fiat" ] 


The Arguments in the VSI is shown as below for 8.x and 10.x: 

8.x 
cars_element_1
cars_element_2

10.x 
cars_0
cars_1

Why the difference and how to fix this?  
Environment:
DevTest 8.x and DevTest 9.5.x or newer
Cause:
We have changed the way we parse JSON arguments in DevTest version 9.5.1 or newer.
 DevTest 8.x uses JSON v1 DPH and  and DevTest9.5.x  or newer  uses JSON v2 DPH.  

In JSON v1 DPH , we transparently convert the JSON to XML before storing it in the VSI; this would then be converted back to JSON when issuing a response.   When the JSON v1 DPH would parse the request arguments from an array in the internal XML, it used the “arrayName_element_X” key template, where arrayName is the name of the array (in this case “cars”), and X is the index of the element starting at 0.
 
The newer JSON v2 DPH, by contrast, keeps the JSON from the request as-is and doesn’t convert it to any different format.  When it parses request arguments from the incoming JSON, it walks the JSON structure and when it finds an array, it uses the “arrayName_x” key template, where arrayName is the name of the array (in this case “cars”) and X is the index of the element in the array starting at 0.
Resolution:

Option 1: 
  • Re-record the JSON VS in 9.5.x or newer versions to use JSON v2 DPH .    
Option 2: 
  • In the existing VSM, Use the Request Data Manager DPH on the request-side to move/rename all the “cars_X” arguments to “cars_element_X”. In the Request Data Manager GUI, you will need to create as many entries as needed to move/rename each desired request argument – this is done using the Move action. So, after importing transactions in 10.1, you will need to make sure to include the Request Data Manager DPH in the request side handlers and place it after the JSON v2 DPH – this will ensure that the Request Data Manager is using data already parsed by the JSON DPH.