Skip to content

Latest commit

 

History

History
47 lines (31 loc) · 1.21 KB

README.md

File metadata and controls

47 lines (31 loc) · 1.21 KB

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