Hello,
Firstly, thanks for exiftool.
When a photo has a latitude or longitude of 0 the -json output format casts the value as a string instead of a float.
exiftool -ver
10.37
exiftool -stay_open True -common_args -G -n -overwrite_original /Users/jmathai/Downloads/source/IMG_9414.jpg -json | grep 'Composite:GPS'
"Composite:GPSAltitude": 1762,
"Composite:GPSDateTime": "2015:07:22 20:31:12Z",
"Composite:GPSLatitude": 51.55325,
"Composite:GPSLongitude": "-0.00417777777777778",
"Composite:GPSPosition": "51.55325 -0.00417777777777778",
The problem is that some JSON parsers have problems with numbers that have too many significant digits, so ExifTool returns them as a string if the number has more than 16 digits after the decimal point. This prevents errors with some JSON parsers (and potential loss of precision).
- Phil
Okay. So it's not about the 0 degree value but the number of decimal values.
That makes sense to me. As a consumer of the JSON output I'd prefer to always have it be a string in that case. For a strongly typed language it becomes a very difficult to track down bug if it *sometimes* returns a string without any real heuristics on being able to determine when, without looking at the source - of course.
Nonetheless, we patched it in our software and thanks again for this wonderful tool.
I should document this somehow. Below are examples showing all of the possible ways that JSON values are formatted. The formatting is based only on the tag value. This is true for all tags.
> # ---- a simple string ----
> exiftool a.jpg -comment=test
1 image files updated
> exiftool a.jpg -comment -j
[{
"SourceFile": "a.jpg",
"Comment": "test"
}]
> # ---- a number ----
> exiftool a.jpg -comment=123
1 image files updated
> exiftool a.jpg -comment -j
[{
"SourceFile": "a.jpg",
"Comment": 123
}]
> # ---- a boolean value ----
> exiftool a.jpg -comment=true
1 image files updated
> exiftool a.jpg -comment -j
[{
"SourceFile": "a.jpg",
"Comment": true
}]
> # ---- special characters ----
> exiftool a.jpg -comment='\ " 	 
 
' -E
1 image files updated
> exiftool a.jpg -comment -j
[{
"SourceFile": "a.jpg",
"Comment": "\\ \" \t \r \n"
}]
> # ---- control characters ----
> exiftool a.jpg -comment="�" -E
1 image files updated
> exiftool a.jpg -comment -j
[{
"SourceFile": "a.jpg",
"Comment": "\u0000\u0001\u0002"
}]
> # ---- binary data (not valid UTF-8) ----
> exiftool a.jpg -comment=`echo -e "test\xff"`
1 image files updated
> exiftool a.jpg -comment -j
[{
"SourceFile": "a.jpg",
"Comment": "test?"
}]
> exiftool a.jpg -comment -j -b
[{
"SourceFile": "a.jpg",
"Comment": "base64:dGVzdP8="
}]
(note: example above was using the bash shell)
- Phil