I can't make sense of any of the documentation. Can someone please provide an example of how I can parse the following shortened exiftool
output using the Haskell module Text.JSON
? The data is generating using the command exiftool -G -j <files.jpg>
.
[{
"SourceFile": "DSC00690.JPG",
"ExifTool:ExifToolVersion": 7.82,
"File:FileName": "DSC00690.JPG",
"Composite:LightValue": 11.6
},
{
"SourceFile": "DSC00693.JPG",
"ExifTool:ExifToolVersion": 7.82,
"File:FileName": "DSC00693.JPG",
"EXIF:Compression": "JPEG (old-style)",
"EXIF:ThumbnailLength": 4817,
"Composite:LightValue": 13.0
},
{
"SourceFile": "DSC00694.JPG",
"ExifTool:ExifToolVersion": 7.82,
"File:FileName": "DSC00694.JPG",
"Composite:LightValue": 3.7
}]
Thanks to all. From your suggestions I was able to put together the following which translates the JSON back into name-value pairs.
Unfortunately, it seems the library is unable to translate the JSON straight back into a simple Haskell data structure. In Python, it is a one-liner:
json.loads(s)
.Well, the easiest way is to get back a JSValue from the json package, like so (assuming your data is in text.json):
this just gives you a generic json Haskell data type.
The next step will be to define a custom Haskell data type for your data, and write an instance of JSON for that, that converts between JSValue's as above, and your type.