https://bz.apache.org/bugzilla/show_bug.cgi?id=59149

Balendra <[email protected]> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|RESOLVED                    |REOPENED
         Resolution|INVALID                     |---

--- Comment #2 from Balendra <[email protected]> ---
I think that was mistakenly left out # in script itself but its not able to
parse JSON .

The real Bean shell code:

import org.json.simple.JSONArray;
import org.json.simple.JSONObject;
import org.json.simple.parser.JSONParser;
import org.json.simple.parser.ParseException;
import java.lang.String;
import java.util.*;
import java.lang.Integer;
import org.json.simple.JSONObject;
import java.io.*;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
String jsonString = prev.getResponseDataAsString();



log.info("This is Output Data: "+jsonString);
JSONParser jsonParser = new JSONParser();
                JSONObject jsonobj = null;
        try {
            jsonobj = (JSONObject) jsonParser.parse(jsonString);
        } catch (ParseException e) {
            // TODO Auto-generated catch block
            log.info("Error in my script", e);
            e.printStackTrace();
        }
        //System.out.println("This is object :"+jsonobj.toString());
        JSONObject obj= (JSONObject)jsonobj.get("query");
        JSONObject obj1= (JSONObject)obj.get("results");
        JSONArray objarr=(JSONArray) obj1.get("mediaObj");
        for(int i=0;i<objarr.size();i++){

            //System.out.println("Print all json oobject under mediaObj
:"+objarr.get(i).toString());
            JSONObject jsobj= (JSONObject) objarr.get(i);
            JSONArray ar=(JSONArray) jsobj.get("streamProfiles");
            JSONObject obj3= (JSONObject)ar.get(0);
            //System.out.println(obj3.get("host"));
            log.info("This is host extracted Data: "+host);

            }


###### Log file:
2016/03/09 08:48:06 INFO  - jmeter.util.BeanShellTestElement: Error in my
script Unexpected character (#) at position 0.
    at org.json.simple.parser.Yylex.yylex(Unknown Source)
    at org.json.simple.parser.JSONParser.nextToken(Unknown Source)
    at org.json.simple.parser.JSONParser.parse(Unknown Source)
    at org.json.simple.parser.JSONParser.parse(Unknown Source)
    at org.json.simple.parser.JSONParser.parse(Unknown Source)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at bsh.Reflect.invokeMethod(Reflect.java:134)
    at bsh.Reflect.invokeObjectMethod(Reflect.java:80)
    at bsh.Name.invokeMethod(Name.java:858)
    at bsh.BSHMethodInvocation.eval(BSHMethodInvocation.java:75)
    at bsh.BSHPrimaryExpression.eval(BSHPrimaryExpression.java:102)
    at bsh.BSHPrimaryExpression.eval(BSHPrimaryExpression.java:47)
    at bsh.BSHCastExpression.eval(BSHCastExpression.java:60)
    at bsh.BSHAssignment.eval(BSHAssignment.java:77)
    at bsh.BSHBlock.evalBlock(BSHBlock.java:130)
    at bsh.BSHBlock.eval(BSHBlock.java:80)
    at bsh.BSHBlock.eval(BSHBlock.java:46)
    at bsh.BSHTryStatement.eval(BSHTryStatement.java:86)
    at bsh.Interpreter.eval(Interpreter.java:645)
    at bsh.Interpreter.eval(Interpreter.java:739)
    at bsh.Interpreter.eval(Interpreter.java:728)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at
org.apache.jmeter.util.BeanShellInterpreter.bshInvoke(BeanShellInterpreter.java:170)
    at
org.apache.jmeter.util.BeanShellInterpreter.eval(BeanShellInterpreter.java:197)
    at
org.apache.jmeter.util.BeanShellTestElement.processFileOrScript(BeanShellTestElement.java:151)
    at
org.apache.jmeter.extractor.BeanShellPostProcessor.process(BeanShellPostProcessor.java:64)
    at
org.apache.jmeter.threads.JMeterThread.runPostProcessors(JMeterThread.java:750)
    at
org.apache.jmeter.threads.JMeterThread.process_sampler(JMeterThread.java:452)
    at org.apache.jmeter.threads.JMeterThread.run(JMeterThread.java:261)
    at java.lang.Thread.run(Thread.java:745)

2016/03/09 08:48:06 ERROR - jmeter.util.BeanShellInterpreter: Error invoking
bsh method: eval    Sourced file: inline evaluation of: ``import
org.json.simple.JSONArray; import org.json.simple.JSONObject; import org. . . .
'' : Typed variable declaration 


Just import the jmx given and paste above Bean Shell Post processor.

-- 
You are receiving this mail because:
You are the assignee for the bug.

Reply via email to