You can simplify this by reversing the logic:

```
if not diffs:
    return json.dumps({})

# rest of code here
```