Possible to have nested group names in JSON?

Started by User93848562, October 04, 2024, 04:44:48 AM

Previous topic - Next topic

User93848562

I noticed that the output of -json -g:0:1:2 gives output such as:

[
  {
    "ExifTool:ExifTool:ExifTool": {
      "ExifToolVersion": 12.76
    },
    "SourceFile": "./_DSC5848.JPG",
    "File:System:Other": {
      "FileName": "_DSC5848.JPG",
      "Directory": ".",
      "FileSize": "82 kB",
      "FilePermissions": "-rw-r--r--"
    },
    "EXIF:ExifIFD:Camera": {
      "ExposureProgram": "Aperture-priority AE",
      "MaxApertureValue": 1.4,
      "Sharpness": "Normal"
    },
    "File:System:Time": {
      "FileModifyDate": "2024:09:24 14:10:16-07:00",
      "FileAccessDate": "2024:09:28 00:13:26-07:00",
      "FileInodeChangeDate": "2024:09:25 23:26:20-07:00"
    },
    "EXIF:ExifIFD:Image": {
      "ExposureTime": "1/50",
      "FNumber": 4.0,
      "ISO": 200
    }
  },
  { ... },
  { ... },
  { ... },
  { ... }
]

Is there a way to tell ExifTool to break out the group names into nested objects?  So the above would be:

[
  {
    "ExifTool": {
      "ExifTool": {
        "ExifTool": {
          "ExifToolVersion": 12.76
        }
      }
    },
    "SourceFile": "./_DSC5848.JPG",
    "File": {
      "System": {
        "Other": {
          "FileName": "_DSC5848.JPG",
          "Directory": ".",
          "FileSize": "82 kB",
          "FilePermissions": "-rw-r--r--"
        },
        "Time": {
          "FileModifyDate": "2024:09:24 14:10:16-07:00",
          "FileAccessDate": "2024:09:28 00:13:26-07:00",
          "FileInodeChangeDate": "2024:09:25 23:26:20-07:00"
        }
      }
    },
    "EXIF": {
      "ExifIFD": {
        "Camera": {
          "ExposureProgram": "Aperture-priority AE",
          "MaxApertureValue": 1.4,
          "Sharpness": "Normal"
        },
        "Image": {
          "ExposureTime": "1/50",
          "FNumber": 4.0,
          "ISO": 200
        }
      }
    }
  },
  { ... },
  { ... },
  { ... },
  { ... }
]

If there is not, can I put in a feature request, maybe a -strict-struct option? 😀

Phil Harvey

There is no way to do this currently.  I suggest reprocessing the JSON to achieve the structure you require -- doing this in ExifTool would be a very low priority item.

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).