I am getting an error in rest assured automation in eclipse using testng

17 views Asked by At

Exception in thread "main" io.restassured.path.json.exception.JsonPathException: Failed to parse the JSON document at io.restassured.path.json.JsonPath$ExceptionCatcher.invoke(JsonPath.java:1002) at io.restassured.path.json.JsonPath$4.doParseWith(JsonPath.java:967) at io.restassured.path.json.JsonPath$JsonParser.parseWith(JsonPath.java:1047) at io.restassured.path.json.JsonPath.get(JsonPath.java:202) at io.restassured.path.json.JsonPath.getInt(JsonPath.java:237) at ComplexJsonParse.main(ComplexJsonParse.java:12) Caused by: groovy.json.JsonException: Lexing failed on line: 3, column: 4, while reading '+', no possible valid JSON value or punctuation could be recognized. at groovy.json.JsonLexer.nextToken(JsonLexer.java:86) at groovy.json.JsonLexer$nextToken.call(Unknown Source) at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:45) at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:125) at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:130) at io.restassured.internal.path.json.ConfigurableJsonSlurper.parseObject(ConfigurableJsonSlurper.groovy:227) at io.restassured.internal.path.json.ConfigurableJsonSlurper.this$2$parseObject(ConfigurableJsonSlurper.groovy) at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:103) at java.base/java.lang.reflect.Method.invoke(Method.java:580) at org.codehaus.groovy.runtime.callsite.PlainObjectMetaMethodSite.doInvoke(PlainObjectMetaMethodSite.java:43) at org.codehaus.groovy.runtime.callsite.PogoMetaMethodSite$PogoCachedMethodSiteNoUnwrapNoCoerce.invoke(PogoMetaMethodSite.java:198) at org.codehaus.groovy.runtime.callsite.PogoMetaMethodSite.callCurrent(PogoMetaMethodSite.java:62) at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCallCurrent(CallSiteArray.java:49) at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:171) at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:185) at io.restassured.internal.path.json.ConfigurableJsonSlurper.parse(ConfigurableJsonSlurper.groovy:105) at io.restassured.internal.path.json.ConfigurableJsonSlurper$parse.callCurrent(Unknown Source) at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCallCurrent(CallSiteArray.java:49) at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:171) at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:185) at io.restassured.internal.path.json.ConfigurableJsonSlurper.parseText(ConfigurableJsonSlurper.groovy:83) at io.restassured.path.json.JsonPath$4$1.method(JsonPath.java:965) at io.restassured.path.json.JsonPath$ExceptionCatcher.invoke(JsonPath.java:1000) ... 5 more

import files.payload; import io.restassured.path.json.JsonPath;

public class ComplexJsonParse {

public static void main(String[] args) {
    // TODO Auto-generated method stub
    
    JsonPath js2 = new JsonPath(payload.CoursePrice());
    //Print number of courses returned by API
    
    int count = js2.getInt("courses.size()");
    System.out.println(count);
    
    //Print Purchase Amount

I was expecting 3

0

There are 0 answers