Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DefaultJSONOptions produces invalid json as diff string #20

Open
treethought opened this issue Oct 13, 2022 · 0 comments
Open

DefaultJSONOptions produces invalid json as diff string #20

treethought opened this issue Oct 13, 2022 · 0 comments

Comments

@treethought
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant