JSON logging to webhook

With this command in a crontab I want to send a notification to a webhook.

rclone copy local:/home/user/test.txt local:/home/user/tmp/ --use-json-log -v 2>&1 | jq | curl -X POST -H "Content-Type: application/json" -d@- https://example.com/api/webhook/rclone

I get this result.

{
  "level": "info",
  "msg": "\nTransferred:   \t          0 B / 0 B, -, 0 B/s, ETA -\nElapsed time:         0.0s\n\n",
  "source": "accounting/stats.go:528",
  "stats": {
    "bytes": 0,
    "checks": 0,
    "deletedDirs": 0,
    "deletes": 0,
    "elapsedTime": 0.0000438,
    "errors": 0,
    "eta": null,
    "fatalError": false,
    "renames": 0,
    "retryError": false,
    "serverSideCopies": 0,
    "serverSideCopyBytes": 0,
    "serverSideMoveBytes": 0,
    "serverSideMoves": 0,
    "speed": 0,
    "totalBytes": 0,
    "totalChecks": 0,
    "totalTransfers": 0,
    "transferTime": 0,
    "transfers": 0
  },
  "time": "2025-04-21T18:56:13.543172+02:00"

This works if nothing has change on source side. But if change the test.txt then I get this:

{
  "level": "info",
  "msg": "Copied (replaced existing)",
  "object": "test.txt",
  "objectType": "*local.Object",
  "size": 322,
  "source": "operations/copy.go:368",
  "time": "2025-04-21T19:00:01.296463+02:00"
}
{
  "level": "info",
  "msg": "\nTransferred:   \t        322 B / 322 B, 100%, 0 B/s, ETA -\nTransferred:            1 / 1, 100%\nElapsed time:         0.0s\n\n",
  "source": "accounting/stats.go:528",
  "stats": {
    "bytes": 322,
    "checks": 0,
    "deletedDirs": 0,
    "deletes": 0,
    "elapsedTime": 0.001505051,
    "errors": 0,
    "eta": null,
    "fatalError": false,
    "renames": 0,
    "retryError": false,
    "serverSideCopies": 0,
    "serverSideCopyBytes": 0,
    "serverSideMoveBytes": 0,
    "serverSideMoves": 0,
    "speed": 0,
    "totalBytes": 322,
    "totalChecks": 0,
    "totalTransfers": 1,
    "transferTime": 0.001451958,
    "transfers": 1
  },
  "time": "2025-04-21T19:00:01.296904+02:00"
}

This result will not processed from my webhook endpoint because it is no valid json.

How I can solve this? Is there a better way to send a json to a webhook for notification? Thanks

welcome to the forum,

based on a number of forum posts, that is how rclone works with json.

not an expert, but would need to transform the output, maybe
https://stackoverflow.com/questions/53992665/adding-comma-separators-to-otherwise-valid-json-string