Skip to content

A simple library to support validating JSON object equivalence in tests.

License

Notifications You must be signed in to change notification settings

JeremiahSanders/json-equivalence

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

28 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

JSON Equivalence

A simple library to support validating JSON object equivalence in tests.

Build status

Usage

Usage in F# Projects

open Jds.JsonEquivalence

let sampleJson = """{"identity":"one"}"""
let otherJson = """{"identity":"One"}"""

let caseInsensitiveOptions = EquivalenceOptions(EquivalenceValueOptions(false), EquivalencePropertyOptions.Default)

EquivalenceComparer.AreStrictlyEquivalent(sampleJson, otherJson)
// false

EquivalenceComparer.AreEquivalent(caseInsensitiveOptions, sampleJson, otherJson)
// true

Usage in C# Projects

using Jds.JsonEquivalence;

const string sampleJson = @"{""identity"":""one""}";
const string otherJson = @"{""identity"":""One""}";

// Equivalent to EquivalencePropertyOptions.Default
var propertyOptions = EquivalencePropertyOptions.ofIgnoredPaths(System.Array.Empty<string>());

var caseInsensitiveOptions = new EquivalenceOptions(
  EquivalenceValueOptions.CaseInsensitive,
  propertyOptions
);

EquivalenceComparer.AreStrictlyEquivalent(sampleJson, otherJson);
// false

EquivalenceComparer.AreEquivalent(caseInsensitiveOptions, sampleJson, otherJson);
// true

About

A simple library to support validating JSON object equivalence in tests.

Resources

License

Stars

Watchers

Forks

Packages

No packages published