ExifTool Forum

ExifTool => Developers => Topic started by: Joanna Carter on July 07, 2021, 06:01:12 AM

Title: Hierarchical keyword read as array losing ordering
Post by: Joanna Carter on July 07, 2021, 06:01:12 AM
Hi folks

Here's a tricky one

I'm using -xmp-lr:hierarchicalsubject to retrieve hierarchical keywords from a file.

This works fine from the macOS Terminal, giving me


Anemonefish|Australian|Amphiprion rubrocinctus


as a single string value but, when I call it from a process in my app, I get an array returned in the JSON dictionary decoded from the data


(lldb) po jsonDict
▿ 2 elements
  ▿ 0 : 2 elements
    - key : "SourceFile"
    - value : /Users/joannacarter/Desktop/Anemonefish, Australian_IMG_1299.jpg
  ▿ 1 : 2 elements
    - key : "HierarchicalSubject"
    ▿ value : 3 elements
      - 0 : Amphiprion rubrocinctus
      - 1 : Anemonefish
      - 2 : Australian

With the words in the wrong order.

Is this possibly a problem with ExifTool or should I be looking to how the data is read?

Although the data reads into an UTF8 string as


"[{\n  \"SourceFile\": \"/Users/joannacarter/Desktop/Anemonefish, Australian_IMG_1299.jpg\",\n  \"HierarchicalSubject\": [\"Amphiprion rubrocinctus\",\"Anemonefish\",\"Australian\"]\n}]\n"
Title: Re: Hierarchical keyword read as array losing ordering
Post by: Phil Harvey on July 07, 2021, 06:16:40 AM
Hi Joanna,

I don't think this is an ExifTool question.  ExifTool will not split HierarchicalSubject on the "|" character.

You need to look at how your app is processing the ExifTool output.

- Phil
Title: Re: Hierarchical keyword read as array losing ordering
Post by: Joanna Carter on July 07, 2021, 06:26:41 AM
Hi Phil

I was afraid of that. As far as I can tell, it's buried deep in the bowels of the Apple process mechanism  >:(
Title: Re: Hierarchical keyword read as array losing ordering
Post by: Joanna Carter on July 07, 2021, 12:01:14 PM
After all that, it turned out to be a very badly mal-formed hierarchicalsubject tag

Normal service has now been resumed  :)