NicholasTD07 / JSONCompare.swift

Compare one dictionary with another (Equatable && diffs)

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

JSONCompare

Compare one dictionary with another (Equatable && diffs)

Roadmap

v1.0.0: Equatable

let jsonValue = json(fromFile: "root_object")
/** root_object.json
 {
   "title": "JSONCompare",
   "isOpensource": true,
   "stars": 999,
   "versions": [
     "v1.0.0: Equatable",
     "v2.0.0: Diff"
   ]
 }
*/

let expected: JSON = .object([
   "title": .string("JSONCompare"),
   "isOpensource": .bool(true),
   "stars": .number(999),
   "versions": .array([
     .string("v1.0.0: Equatable"),
     .string("v2.0.0: Diff"),
   ])
])

print(JSON(jsonValue) == expected) // => true

v2.0.0: Diff

JSON.diff(
  .array([.string("a")],
  .array([.string("b")]
)
/** =>
  .diff(
    [
      .added(.array([.string("b")])),
      .deleted(.array([.string("a")])),
    ]
*/

About

Compare one dictionary with another (Equatable && diffs)

License:MIT License


Languages

Language:Swift 90.8%Language:Makefile 9.2%