jmeter-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Deepak Shetty <shet...@gmail.com>
Subject Re: Require regular expression !!
Date Thu, 31 May 2012 20:03:32 GMT
Hi
I would suggest you read up on the JSON format (www.json.org) .
You can use tools like http://jsonviewer.stack.hu/ to see your JSON in a
more readable format.
Heres a modified snippet that reads two of the values for the input string
you have provided

import org.json.JSONArray;
import org.json.JSONObject;

String jsonString = prev.getResponseDataAsString();
JSONArray equipmentParts = new
JSONObject(jsonString).getJSONArray("root_EquipmentPartBO_GridComponentId");
JSONArray parts = new JSONArray();

for(int i=0;i<equipmentParts.length();i++ ){
    JSONObject equipmentPart = equipmentParts.getJSONObject(i);
    JSONObject part = new JSONObject();

part.put("partId",equipmentPart.getString("EquipmentPartBO_GridComponentId_equipmentPartId_columnId"));

part.put("partNumber",equipmentPart.getString("EquipmentPartBO_GridComponentId_equipmentPartName_columnId"));
    // add more here
    parts.put(part);
}

vars.put("jsonResponse", parts.toString());

regards
deepak

On Thu, May 31, 2012 at 5:26 AM, Nithya Prakash
<nithyaprakash86@gmail.com>wrote:

> Hi Deepak,
>
>
> Thanks a lot for the reply it was very useful.............but i have some
> problem.....the previously posted HTTP response was not the correct one
> .................below is the actually HTTP response we are getting
>
>
>
> {"totalCount": "7","root_EquipmentPartBO_GridComponentId":
>
> [{"EquipmentPartBO_GridComponentId_equipmentPartName_columnId":"SRW224G4P-K9-AU","EquipmentPartBO_GridComponentId_equipmentPartId_columnId":"543650","EquipmentPartBO_GridComponentId_equipmentPartDescription_columnId":"SF
> 300-24P 24-port 10/100 PoE Managed Switch w/Gig
>
> Uplinks","EquipmentPartBO_GridComponentId_equipmentPartLocation_columnId":"HQ","EquipmentPartBO_GridComponentId_equipmentPartRootId_columnId":"543650","EquipmentPartBO_GridComponentId_orderNum_columnId":"","EquipmentPartBO_GridComponentId_equipmentPartVendor_columnId":"CISCO","EquipmentPartBO_GridComponentId_equipmentPartPhysicalSiteId_columnId":"75638","EquipmentPartBO_GridComponentId_validationStatus_columnId":"not
>
> validated","EquipmentPartBO_GridComponentId_solutionId_columnId":"14942211","EquipmentPartBO_GridComponentId_productName_columnId":"SRW224G4P-K9-AU","EquipmentPartBO_GridComponentId_validationMessage_columnId":"","EquipmentPartBO_GridComponentId_equipmentPartSiteId_columnId":"75641","EquipmentPartBO_GridComponentId_equipmentPartQuantity_columnId":"1","EquipmentPartBO_GridComponentId_equipmentPartParentId_columnId":"","EquipmentPartBO_GridComponentId_isIncluded_columnId":"false"},{"EquipmentPartBO_GridComponentId_equipmentPartName_columnId":"UC320W-FXO-K9","EquipmentPartBO_GridComponentId_equipmentPartId_columnId":"543653","EquipmentPartBO_GridComponentId_equipmentPartDescription_columnId":"Small
> Business Unified Communications 320 with 4
>
> FXO","EquipmentPartBO_GridComponentId_equipmentPartLocation_columnId":"HQ","EquipmentPartBO_GridComponentId_equipmentPartRootId_columnId":"543653","EquipmentPartBO_GridComponentId_orderNum_columnId":"","EquipmentPartBO_GridComponentId_equipmentPartVendor_columnId":"CISCO","EquipmentPartBO_GridComponentId_equipmentPartPhysicalSiteId_columnId":"75638","EquipmentPartBO_GridComponentId_validationStatus_columnId":"not
>
> validated","EquipmentPartBO_GridComponentId_solutionId_columnId":"14942211","EquipmentPartBO_GridComponentId_productName_columnId":"UC320W-FXO-K9","EquipmentPartBO_GridComponentId_validationMessage_columnId":"","EquipmentPartBO_GridComponentId_equipmentPartSiteId_columnId":"75639","EquipmentPartBO_GridComponentId_equipmentPartQuantity_columnId":"1","EquipmentPartBO_GridComponentId_equipmentPartParentId_columnId":"","EquipmentPartBO_GridComponentId_isIncluded_columnId":"false"},{"EquipmentPartBO_GridComponentId_equipmentPartName_columnId":"SPA525G2","EquipmentPartBO_GridComponentId_equipmentPartId_columnId":"543654","EquipmentPartBO_GridComponentId_equipmentPartDescription_columnId":"Cisco
> SPA525G2 5-Line IP
>
> Phone","EquipmentPartBO_GridComponentId_equipmentPartLocation_columnId":"HQ","EquipmentPartBO_GridComponentId_equipmentPartRootId_columnId":"543654","EquipmentPartBO_GridComponentId_orderNum_columnId":"","EquipmentPartBO_GridComponentId_equipmentPartVendor_columnId":"CISCO","EquipmentPartBO_GridComponentId_equipmentPartPhysicalSiteId_columnId":"75638","EquipmentPartBO_GridComponentId_validationStatus_columnId":"not
> validated"}]}
>
>
>
> from the above response i need to fetch the
>
> EquipmentPartBO_GridComponentId_equipmentPartName_columnId":"SRW224G4P-K9-AU"
>
>
>
> EquipmentPartBO_GridComponentId_equipmentPartId_columnId":"543650"
>
>
>
> in this way i need to fetch the remaining ones in the following formate
>
>
>
>
> {'partId':'543650','partNumber':'SRW224G4P-K9-AU','productPart':'SRW224G4P-K9-AU','validationStatus':'not
>
> validated'},{'partId':'543653','partNumber':'UC320W-FXO-K9','productPart':'UC320W-FXO-K9','validationStatus':'not
> validated'}.............and so on .............
>
>
>
>  Please can i get Ben shell code for the above HTTP response
>
>
> Thanks
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message