json封装类
public class JsonUtils {
public String getInternalName(JSONObject jo){
String internalName = "";
try {
JSONObject internalJSON = jo.getJSONObject("result");
internalName = internalJSON.getString("city") ;
}catch (Exception e){
e.printStackTrace();
}
return internalName;
}
public String getName(JSONObject jo){
String name = "";
try {
name= jo.getString("code") ;
}catch (Exception e){
e.printStackTrace();
}
return name;
}
public boolean isResponseCorrect(JSONObject jo, String checkpoint, String passValue){
ReadContext context = JsonPath.parse(jo);
JSONArray result = context.read("$.result.."+checkpoint);
String resultString = result.get(0).toString();
if(resultString.equals(passValue)){
return true;
}else{
return false;
}
}
public boolean isResponseCode(JSONObject jo, String checkpoint,String passValue){
String checkName= jo.getString(checkpoint);
if(checkName.equals(passValue)){
return true;
}else{
return false;
}
}
}