JSON file - output formatting

Started by herb, November 24, 2018, 08:05:53 AM

Previous topic - Next topic

herb

Hello Phil,

I have generated a file "test.json" based on an image file "image.jpg" using Exiftool option -json.

With command exiftool.exe -a -G0:1 test.json
I get an output with tagname as Family0Family1Tagname (e.g.: XMPXMP-dc Description) as one string, which is difficult to parse.

Is there the possibility to get this string with family-names seperated e.g. by character :

Thanks in advance
Best regards
Herb

Phil Harvey

Hi Herb,

What was the command you used to produce the JSON file?

- 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 ($).

herb

Hello Phil,

thanks for your answer.

My application sends the following command to generate the *.json file
exiftool.exe -charset filename=utf8 -charset exif=utf8 -charset iptc=utf8 -use mwg -m -G0:1 -wm wcg -a -j -struct -w! %d%f.json -All image.jpg
The first lines of the generated file are as follows:
[{
  "SourceFile": "F:/Struct/image.jpg",
  "ExifTool:ExifToolVersion": 11.20,
  "File:System:FileName": "image.jpg",
  ...


The json file is read by my application with
exiftool.exe -s -t -a -G0:1 -charset filename=utf8 -c %d %.4f -all:all -mwg:all -sep ? -api Filter=ReplaceNL($_) -charset exif=utf8 -charset iptc=utf8 -use mwg -m -api struct=2 image.json

and all lines sent back by Exiftool look like:
ExifTool \t ExifToolVersion \t 11.20
...
JSON \t CompositeAperture \t 8.0

Please note that I replaced TAB with " \t "

Thanks for your help in advance
Best regards
Herb

Phil Harvey

Hi Herb,

When I try this I get a colon between the group names.  So I can't reproduce what you are seeing.

But 2 points:

1) the -wm command does nothing when reading (your first command)

2) the %d %.4f in your second command needs quotes.

- 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 ($).

herb

Hello Phil,

Thanks, that your tried to reproduce my problem.

I am confused that you get colons between the group names.
I only get colons between groupnames for File:System.
For JSON group I always get
JSON CompositeAperture 8.0
JSON CompositeBaseName image
JSON CompositeBigImage (Binary data 7295 bytes, use -b option to extract)
JSON CompositeBlueBalance 1.875
...
JSON EXIFExifIFDFNumber 8.0
JSON EXIFExifIFDFileSource Digital Camera
JSON EXIFExifIFDFlash On, Did not fire

Please see my attached output.txt file.

Thanks also for your helpful hints:
Yes, option -wm does nothing in case of reading. My application has to become more clever.
Yes, -c  %d %.4f needs quotes in case of working with DOS-box. But I forgot to mention that my application uses -stay_open and sends the commands via pipe.

Best regards
Herb

Phil Harvey

OK, I understand now.  Let me think about this.

- 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 ($).

Phil Harvey

I wanted to understand what you are trying to do so I could figure out how best to help.  Unfortunately I'm still a bit in the dark.  (I'm a bit afraid that I may be asking for a TLDR here.)

The basic problem is that ExifTool reads the generic JSON format when presented with a JSON "image" file.  It doesn't do anything special to interpret the tag names as ExifTool groups.

The -j output is designed to be read back in using the -j option, but you don't get the same ExifTool groups when reading as an image file.  It can't do this because there is no way for ExifTool to know what command you used to produce the JSON file, so it can't know the which family the group prefixes belong to.

The -X output is different because it always uses fixed families, but it still may not do everything you want.

- 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 ($).

herb

Hello Phil,

ok, I understand.

Thanks for your investigations and help.

Best regards
Herb