Quantcast
Channel: Silk Performer
Viewing all articles
Browse latest Browse all 4084

Forum Post: RE: How to capture JSON response in silk performer and using http/html protocol?

$
0
0
He is a little sample against our public website. You should be able to run it on your machine. It reuses some code from one of my blog posts: community.microfocus.com/.../json-bdl-api-sample-and-jsonpath-alternative Hope this gets you started to learn the necessary Silk Performer functions. ///// ///// benchmark WebBenchmarkName use "WebAPI.bdh" use "json.bdh" const SOME_JSON := "" " { \"store\": {" " \"book\": [ " " { \"category\": \"reference\"," " \"author\": \"Nigel Rees\"," " \"title\": \"Sayings of the Century\"," " \"price\": 8.95" " }," " { \"category\": \"fiction\"," " \"author\": \"Evelyn Waugh\"," " \"title\": \"Sword of Honour\"," " \"price\": 12.99," " \"isbn\": \"0-553-21311-3\"" " }" " ]," " \"bicycle\": {" " \"color\": \"red\"," " \"price\": 19.95" " }" " }" "} " ; // Workload Section dcluser user WebUser transactions TWeb : 1; // Web Transactions Section dcltrans transaction TWeb var sResult : string ; hJsonRoot, hJsonStore, hJsonBookArray, hJsonBook : number ; begin // 1) retrieve web response, e.g. WebParseDataBound(sResult); // this page echoes the same content sent to the site back to the user WebPagePost( " http://demo.borland.com/testsite/echopost.asp" , SOME_JSON, STRING_COMPLETE, "application/json" , "getBooks" ); // 2) parse as json; see also blog: // community.microfocus.com/.../json-bdl-api-sample-and-jsonpath-alternative hJsonRoot := JsonParse(SOME_JSON); // under the root element, there is a property 'store', which is an object JsonGetObjectProperty(hJsonRoot, "store" , hJsonStore); // get the property 'book' which is an array JsonGetArrayProperty(hJsonStore, "book" , hJsonBookArray); // get the 2nd array element (zero-based index), which is an object JsonArrayGetObjectElement(hJsonBookArray, 1, hJsonBook); // get the property 'author', which is a string JsonGetStringProperty(hJsonBook, "author" , sResult); Print( "2nd author is: " +sResult); end TWeb;

Viewing all articles
Browse latest Browse all 4084

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>