Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

Extract JSON from http page request

//get the previous http response and eval it
var resp_ = context.variableManager.getValue("EntryResponse");
if (resp_ == null) {
        context.fail("Variable 'EntryResponse' not found");
}
logger.debug("EntryResponse="+resp_);
var resp = eval("("+resp_+")")

//then used resp as real json
logger.debug("Logged User Id="+resp.data.id);

// Inject a value in a runtime variable
context.variableManager.setValue("UserName", resp.data.id);
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #Extract #JSON #http #page #request
ADD COMMENT
Topic
Name
4+8 =