Skip to content

DefaultJSONOptions produces invalid json as diff string #20

@treethought

Description

@treethought

When using the json options, the returned diff string produces invalid JSON preventing it to be unmarshaled into something more usable.

Example

opts := jsondiff.DefaultJSONOptions()

diff, diffStr = jsondiff.Compare(j0, j1, &opts)
if diff != jsondiff.FullMatch {
   fmt.Println(diffStr)

   m := make(map[string]interface{})
   err := json.Unmarshal([]byte(diffStr), m)
    if err != nil {
       log.Fatal(err)
}

Produces

{
    "prop-removed":{"error": {}
        "prop-removed":{"code": -12001,}
        "prop-removed":{"message": "rate limited"}
    "prop-removed":{}},
    "result": {"changed":[null, "otherVal"]}
}
FATA[2022-10-13T12:05:16-07:00] invalid character '"' after object key:value pair

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