Skip to content

Commit

Permalink
updated README
Browse files Browse the repository at this point in the history
  • Loading branch information
kvnxiao authored Mar 26, 2017
1 parent 474dde2 commit 376e21a
Showing 1 changed file with 15 additions and 17 deletions.
32 changes: 15 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
# JsonEquals

[![Release](https://jitpack.io/v/alphahelix00/jsonequals.svg)]
(https://jitpack.io/#alphahelix00/jsonequals)
[![CircleCI](https://circleci.com/gh/alphahelix00/jsonequals.svg?style=svg)](https://circleci.com/gh/alphahelix00/jsonequals)
[![CircleCI](https://circleci.com/gh/kvnxiao/jsonequals.svg?style=shield)](https://circleci.com/gh/kvnxiao/jsonequals)
[![Release](https://jitpack.io/v/kvnxiao/jsonequals.svg)](https://jitpack.io/#kvnxiao/jsonequals)

JsonEquals is a simple JSON deep-equality comparator for Java.
It ignores the ordering of JSON keys during comparison, and is perfect for comparing JSON responses between production and staging environments when your project is due for an API upgrade.
Expand Down Expand Up @@ -58,7 +57,7 @@ JsonCompareResult result = jsonRootA.compareToWithIgnore(jsonRootB, ignoreList);

### Pruning JSON Arrays

Supply a `Map<String, String>` in a dot-notated JSON path format to expected value in string form to act as a predicate. Any matches will be _**filtered out (read: removed)**_ and therefore ignored during comparison. Note that this _will_ shift the array indices. Use `JsonRoot#compareToWithPrune()`
Supply a `Map<String, String>` in a dot-notated JSON path format to expected value in string form to act as a predicate. Any matches will be _**filtered out (read: removed)**_ before the comparison starts, and therefore ignored during comparison. Note that this _will_ shift the array indices. Use `JsonRoot#compareToWithPrune()`

Format: `Map<String, String>` -> `("arrayIndexObjectPath:fieldName", "valueToFilterInStringForm")`

Expand Down Expand Up @@ -93,7 +92,7 @@ the JSON string:
In the above example, after pruning the JSON file before comparison, the object `$.someObject.someArray[6]` will be removed from comparison, which shifts object `$.someObject.someArray[7]` down to index 6, and so on, until everything that matches has been pruned from the array.
This can be useful when checking a list of responses from two different environments where there can be gaps in the arrays, for example, if we have an array of applications installed, we can define equality as having the same installed apps from both responses by pruning the apps that are not installed.

For a thorough example, see [`IgnoreAndPruneTest.java`](https://github.com/alphahelix00/jsonequals/blob/master/src/test/java/com/github/alphahelix00/jsonequals/tests/IgnoreAndPruneTest.java), along with [`ignore_prune_a.json`](https://github.com/alphahelix00/jsonequals/blob/master/tests/ignore_prune_a.json) and [`ignore_prune_b.json`](https://github.com/alphahelix00/jsonequals/blob/master/tests/ignore_prune_b.json)
For a thorough example, see [`IgnoreAndPruneTest.java`](https://github.com/kvnxiao/jsonequals/blob/master/src/test/java/com/github/kvnxiao/jsonequals/tests/IgnoreAndPruneTest.java), along with [`ignore_prune_a.json`](https://github.com/kvnxiao/jsonequals/blob/master/tests/ignore_prune_a.json) and [`ignore_prune_b.json`](https://github.com/kvnxiao/jsonequals/blob/master/tests/ignore_prune_b.json)

#### Debug Mode

Expand All @@ -105,40 +104,39 @@ Check out the test files for examples.

## Installation

JsonEquals uses JitPack for distribution. See https://jitpack.io/#alphahelix00/jsonequals for more information.
JsonEquals uses JitPack for distribution. See https://jitpack.io/#kvnxiao/jsonequals for more information.

Replace `@VERSION@` with the version number or commit hash.

#### Gradle
```groovy
```gradle
allprojects {
repositories {
...
jcenter()
maven { url 'https://jitpack.io' }
}
}
```
```groovy
```gradle
dependencies {
compile kcom.github.kvnxiaoMaven
compile 'com.github.kvnxiao:jsonequals:1.0.1'
}
```
#### Maven
```xml
...
<repositories>
<repository>
<id>jitpack.io</id>
<url>https://jitpack.io</url>
</repository>
</repositories>
...
```
```xml
...
<dependency>
<groupId>com.github.alphahelix00</groupId>
com.github.kvnxiaols</artifactId>
<version>-SNAPSHOT</version>
<groupId>com.github.kvnxiao</groupId>
<artifactId>jsonequals</artifactId>
<version>1.0.1</version>
</dependency>
...
```

## Contributing
Expand Down

0 comments on commit 376e21a

Please sign in to comment.