http://jsonassert.skyscreamer.org/

从这个网站下载jsonassert-1.5.0.jar ,也可以下载到源代码

JSONObject data = getRESTData("/friends/367.json");
String expected = "{friends:[{id:123,name:\"Corby Page\"},{id:456,name:\"Carter Page\"}]}";
JSONAssert.assertEquals(expected, data, false);

SoapUI里面没有这个jar,把它放在lib目录下,在SoapUI里面调用如下:

import org.skyscreamer.jsonassert.*
import org.json.JSONObject def currentStepIndex = context.currentStepIndex
def previousStepName = testRunner.testCase.getTestStepAt(currentStepIndex-1).name
def prePreStepName = testRunner.testCase.getTestStepAt(currentStepIndex-2).name
try{
def expectedJson = new JSONObject(context.expand( '${'+prePreStepName+'#Response}' ))
def actualJson = new JSONObject(context.expand( '${'+previousStepName+'#Response}' )) //When strict is set to false (recommended), it forgives reordering data and extending results (as long as all the expected elements are there), making tests less brittle.
JSONAssert.assertEquals(expectedJson, actualJson, false)
}catch(Exception e){
log.info e
}

  

[SoapUI] Compare JSON Response(比较jsonobject)的更多相关文章

  1. 使用Groovy处理SoapUI中Json response

    最近工作中,处理最多的就是xml和json类型response,在SoapUI中request里面直接添加assertion处理json response的话,可以采用以下方式: import gro ...

  2. [SoapUI] 比较JSON Response

    比较两个JSON, ID是数字时,处理成统一的格式:只保留小数点后5位 package direct; import org.json.JSONArray; import org.json.JSONE ...

  3. 【SoapUI】比较Json response

    package direct; import org.json.JSONArray; import org.json.JSONException; import org.json.JSONObject ...

  4. [SoapUI] 重载JSONComparator比对JSON Response,忽略小数点后几位,将科学计数法转换为普通数字进行比对,在错误信息中打印当前循环的case number及其他附加信息

    重载JSONComparator比对JSON Response,忽略小数点后几位,将科学计数法转换为普通数字进行比对,在错误信息中打印当前循环的case number及其他附加信息 package d ...

  5. grails框架中读取txt文件内容将内容转换为json格式,出现异常Exception in thread "main" org.json.JSONException: A JSONObject text must begin with '{' at character 1 of [...]

    Exception in thread "main" org.json.JSONException: A JSONObject text must begin with '{' a ...

  6. datatable fix error–Invalid JSON response

    This error is pretty common. Meaning:When loading data by Ajax(ajax|option).DataTables by default, e ...

  7. java 字符串解析为json 使用org.json包的JSONObject+JSONArray

    参考: https://blog.csdn.net/xingfei_work/article/details/76572550 java中四种json解析方式 JSONObject+JSONArray ...

  8. org.json.JSONException: A JSONObject text must begin with '{' at character 1 of {解决方法

    在使用java读取一个本地的json配置文件的时候,产生了这个异常:org.json.JSONException: A JSONObject text must begin with '{' at c ...

  9. [SoapUI] 通过JSONAssert比较两个环境的JSON Response,定制化错误信息到Excel

    package ScriptLibrary; import org.json.JSONArray; import org.json.JSONException; import org.json.JSO ...

随机推荐

  1. http协议和https协议

    内容: 1.http协议介绍 2.https协议介绍 3.http协议和https协议对比 1.http协议介绍 (1)http协议是什么 1 一个传输协议,协议就是双方都遵守的规范. 2 为什么叫超 ...

  2. Bogart gData.vb

    Imports System Imports System.Data Imports System.Data.OleDb Imports Microsoft.VisualBasic Imports S ...

  3. tornado-模板,转义,上传静态文件

    class MainHandler(tornado.web.RequestHandler): def get(self): self.render("ces.html") def ...

  4. css的样式

    <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...

  5. rsync同步web数据

    rsync远程同步web服务器的数据 实验拓扑                                            服务器A(rsync服务器)--------------服务器B( ...

  6. ganglia

    A.lamp界面快速搭建---------------------------------------------------------------------------------------- ...

  7. 如何从编程的本质理解JVM内存模型

    如何从编程的本质理解JVM内存模型 一般聊JVM内存模型都是把图截出来,然后对着图,解释上面堆.栈之类的概念.这篇将分享下,如何从编程的本质上理解,JVM内存模型是什么样子,为什么是这个样子,不再死记 ...

  8. Latex 箭头、下标、符号上下写文字、正方形和三角形

    0. hat   $abc\hat def$  $ab\widehat{cde}f$ 1. 箭头上的文字    $\underrightarrow{\text{你的文字}}$  ($A \xlefta ...

  9. 6.package配置相关

    转自:https://wenku.baidu.com/view/84fa86ae360cba1aa911da02.html 属性名 是否必须 说明 Name 是 Package的唯一标识,不允许同名 ...

  10. Others-接口集成方式

    1. 异步通信方式可分为不互锁.半互锁和全互锁三种类型: a.不互锁方式 主模块发出请求信号后,不等待接到从模块的回答信号,而是经过一段时间.确认从模块已收到请求信号后,便撤消其请求信号:从设备接到请 ...