Json串比较

      在diff接口返回值的时候需要比较两个json串是否一致,此时通过JSONCompare.compareJSON可以实现,直接上代码:

package testCode;

import com.alibaba.fastjson.JSONObject;
import org.skyscreamer.jsonassert.JSONCompare;
import org.skyscreamer.jsonassert.JSONCompareResult;
import org.skyscreamer.jsonassert.JSONCompareMode;

public class TestJsonCompare {



    public static void main(String args[]){
        String s1 = "{\n" +
                "    \"store\": {\n" +
                "        \"book\": [\n" +
                "            {\n" +
                "                \"category\": \"reference\",\n" +
                "                \"author\": \"Nigel Rees\",\n" +
                "                \"title\": \"Sayings of the Century\",\n" +
                "                \"price\": 

你可能感兴趣的:(JAVA)