public class JsonAssert extends Object
{} is not verified{"one":1, "two":2}
matches {"one":1}[] is not verified by default, for example [1, 2]
matches [2, 1]. This mode can be disabled with withStrictArrayOrder(){"foo": "2015-01-01T13:00:00+2000"}
matches {"foo": "2015-01-01T10:00:00-1000"}. This feature can be disabled with
withStrictTimezone()
String actual = "{}";
String expected = "{}";
JsonAssert.assertJson(actual).isSimilarTo(expected);
Expected JSON document can be loaded from URLs:
String actual = "{}";
JsonAssert.assertJson(actual).isSimilarTo(getClass().getResource("MyTest/expected.json"));
| Modifier and Type | Method and Description |
|---|---|
static JsonAssert |
assertJson(String actualJson) |
static JsonAssert |
assertJson(URL actualJson) |
JsonAssert |
ignoreFields(String... ignoredFields) |
JsonAssert |
isSimilarTo(String expected) |
JsonAssert |
isSimilarTo(URL expected) |
JsonAssert |
withStrictArrayOrder() |
JsonAssert |
withStrictTimezone() |
public JsonAssert withStrictTimezone()
public JsonAssert withStrictArrayOrder()
public JsonAssert ignoreFields(String... ignoredFields)
public JsonAssert isSimilarTo(String expected)
public JsonAssert isSimilarTo(URL expected)
public static JsonAssert assertJson(String actualJson)
public static JsonAssert assertJson(URL actualJson)
Copyright © 2009–2016 SonarSource. All rights reserved.