Skip to content

diffJson with dates, returns empty curly braces  #102

Closed
@dr-dimitru

Description

@dr-dimitru

Example:

var after = {
  "fingerprint" : "string1",
  "valid_to" : new Date("2016-08-14T23:59:59Z"),
  "valid_from" : new Date("2016-02-12T00:00:00Z")
};

var before = {
  "fingerprint" : "string 2",
  "valid_from" : new Date("2016-02-12T00:00:00Z"),
  "valid_to" : new Date("2016-02-20T03:58:53Z")
};

JsDiff.diffJson(before, after);

Result:

[
  {
    "count": 1,
    "value": "{\n"
  },
  {
    "count": 1,
    "removed": true,
    "value": "  \"fingerprint\": \"string 2\",\n"
  },
  {
    "count": 1,
    "added": true,
    "value": "  \"fingerprint\": \"string1\",\n"
  },
  {
    "count": 3,
    "value": "  \"valid_from\": {},\n  \"valid_to\": {}\n}"
  }
]

Expected result:

[
  {
    "count": 1,
    "value": "{\n"
  },
  {
    "count": 1,
    "removed": true,
    "value": "  \"fingerprint\": \"string 2\",\n"
  },
  {
    "count": 2,
    "added": true,
    "value": "  \"fingerprint\": \"string 1\",\n  \"valid_to\": \"2016-11-20T03:58:53.000Z\",\n"
  },
  {
    "count": 1,
    "value": "  \"valid_from\": \"2015-11-20T01:36:42.000Z\",\n"
  },
  {
    "count": 1,
    "removed": true,
    "value": "  \"valid_to\": \"2016-02-14T03:58:53.000Z\"\n"
  },
  {
    "count": 1,
    "value": "}"
  }
]

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions