I would like very much to be able to "easier" parse the JSON output of exiftool.
I have the following issues:
[{
"SourceFile": "b.jpg",
"ExifTool:ExifToolVersion": {
"id": "ExifToolVersion",
"table": "Extra",
"val": 12.62
},
"File:System:FileName": {
"id": "FileName",
"table": "Extra",
"val": "b.jpg"
},
...
]
* the array contains different object types ("SourceFile" which is just a string, and the rest...which are something else...).
* each of the objects is different
* for G0:1 they don't all have same length("ExifTool:ExifToolVersion" vs "File:System:FileName") (as in non json output)
* having field names with : inside makes it impossible to map them to some object / models in programming languages
* having val as either string or number makes it difficult to bind / deserialize
Somehow JSON should also be "machine" readable, so I would suggest to have something more deserialization friendly like:
[{
"g0":"File";
"g1":"System";
...g2, etc
"tagName":"FileName",
"id": "FileName",
"table": "Extra",
"stringVal": "b.jpg", // not null for strings, omitted for other types
"intVal": null, // not null for integers, omitted for other types
"doubleVal": null, // not null for double, omitted for other types
"structVal": null // not null for structs (can be of any content just not with member names that contain : or other illegal chars)
},..
]
It could really help all the people that are trying to use this tool from Java or C# or others.
Thanks a lot...
Wow. That would be a cumbersome output.
What about just auto-detecting the type? It is a string if it is quoted. Otherwise it is a double if it contains a decimal point, or integer if it doesn't. Or a structure if it begins with a brace.
As for the variable number of groups, use -G:0:1 to always show both groups. You could change the colons to underlines in your code if they are a problem for you.
- Phil