https://github.com/jar-b/jsondup
Detect duplicate keys in a JSON object.
https://github.com/jar-b/jsondup
Last synced: 8 months ago
JSON representation
Detect duplicate keys in a JSON object.
- Host: GitHub
- URL: https://github.com/jar-b/jsondup
- Owner: jar-b
- License: mit
- Created: 2023-09-12T17:52:14.000Z (about 2 years ago)
- Default Branch: main
- Last Pushed: 2023-09-20T18:08:10.000Z (about 2 years ago)
- Last Synced: 2025-02-07T12:47:44.159Z (10 months ago)
- Language: Go
- Size: 14.6 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# jsondup
[](https://github.com/jar-b/jsondup/actions/workflows/build.yml)
Detect duplicate keys in a JSON object.
## Installation
```console
go install github.com/jar-b/jsondup/cmd/jsondup@latest
```
## Usage
```console
$ jsondup -h
Detect duplicate keys in a JSON object.
Usage: jsondup [filename]
```
## Examples
### Simple
Given the following content in `dup.json`:
```json
{
"a": "foo",
"a": "bar"
}
```
```console
$ jsondup dup.json
2023/09/12 15:53:29 duplicate key "a"
```
### Nested
A more complex example might be an AWS IAM policy document with duplicated `Condition` keys:
```json
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": "s3:PutObject",
"Resource": "*",
"Condition": {
"StringEquals": {
"s3:prefix": ["one/", "two/"]
},
"StringEquals": {
"s3:versionid": "abc123"
}
}
}
]
}
```
```console
$ jsondup iam.json
2023/09/12 15:57:15 duplicate key "Statement.0.Condition.StringEquals"
```