/jjjson

Primary LanguageJavaGNU General Public License v3.0GPL-3.0

jjjson

Small tools to operate JSON, especially in API test automation.

Run Tests

Sorter

Used to compare JSONs by content, when it should be same, while order might be diffrent.

{
  "f1" : "Just wanted to say",
  "f2" : "I love you"
}

{
  "f2" : "I love you",
  "f1" : "Just wanted to say"
}

So this will result false positive failure:

var expected = { "f1" : "Just wanted to say", "f2" : "I love you" }
var actual = { "f2" : "I love you", "f1" : "Just wanted to say" }
Assert.assertEquals(expected, actual)

While will not if sort it before comparing:

var expected = JsonSorter.getSortedJson({ "f1" : "Just wanted to say", "f2" : "I love you" })
var actual = JsonSorter.getSortedJson({ "f2" : "I love you", "f1" : "Just wanted to say" })
Assert.assertEquals(expected, actual)

Usage

Library is being published to Maven Central Repository, so usage is same as any other library.

Maven

<dependencies>
    <dependency>
        <groupId>io.siniavtsev</groupId>
        <artifactId>jjjson</artifactId>
        <version>1.0.0</version>
    </dependency>
</dependencies>

Gradle

dependencies {
    implementation 'io.siniavtsev:jjjson:1.0.0'
}