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. smyfony2 增删改查

    1查询和修改

  2. 40. Linux下7-zip解压到当前目录的命令

    7z x test.zip 解压到当前目录下,但保留原来的目录结构 7z e test.zip 解压到当前目录下,不保留原来的目录结构

  3. TestNG中DataProvider的用法

    提供数据的一个测试方法.注解的方法必须返回一个Object[] [],其中每个对象 []的测试方法的参数列表中可以分配.该@Test 方法,希望从这个 DataProvider 的接收数据,需要使用一 ...

  4. 文件的基本操作(python)

    文件打开: 1. f = open('yesterday,‘r+’,encoding = ‘utf-8’) 读取的方式加载为Utf-8 r    打开文件并写, 只适用于文字类 r+   打开文件并读 ...

  5. Spring MVC 异常处理 - DefaultHandlerExceptionResolver

    对一些特殊的异常进行处理,比如方法类型不匹配, 转换错误.

  6. Simple2D-18(音乐播放器)使用 bass 音频库

    BASS 简介 BASS是一个在多个平台上用于软件的音频库.其目的是为开发人员提供功能强大且高效的示例流(MP3,MP2,MP1,OGG,WAV,AIFF),MOD 音乐(XM,IT,S3M,MOD ...

  7. 认识serviceLoader

    最近在研究系统设计方面的东西,发现有很多通用的解决方案,包括spring配置扩展以及serviceLoader的应用,这里简单记录下serviceLoader的简单应用,网上例子很多,大同小异,本人觉 ...

  8. 使用flash导出图集动画到unity

    1.选中要导出的元件,元件所有动作要对齐,右键导出Sprite Sheet.. 2.设置如下 3.复制导出的png图片到unity,对图片进行网格裁剪,网格宽高在plist文件中:

  9. c++实现贪食蛇

    今天老师布置了作业 让我们观察c++实现贪食蛇的代码 #include<windows.h> #include<time.h> #include<stdlib.h> ...

  10. JSP共享javabean

    JavaBean是一种可重复使用,且跨平台的软件组件.JavaBean可分为两种:一种是有用户界面(UI)的javaBean:还有一种是没有用户界面,主要负责处理事务(如数据运算,操纵数据库)的jav ...