add tag as JSON gets encoded

Started by mrharel, May 05, 2020, 08:16:16 AM

Previous topic - Next topic

mrharel

Hi,
I have created a config file for custom tags for XMP, where one of the fields is suppose to be a JSON input.

%Image::ExifTool::UserDefined = (
    'Image::ExifTool::XMP::Main' => {
        MyNS => { # <-- must be the same as the NAMESPACE prefix
            SubDirectory => {
                TagTable => 'Image::ExifTool::UserDefined::MyNS',
                # (see the definition of this table below)
            },
        },
    },
);

%Image::ExifTool::UserDefined::MyNS = (
    GROUPS        => { 0 => 'XMP', 1 => 'XMP-MyNS', 2 => 'Image' },
    NAMESPACE     => { 'MyNS' => 'http://ns.myname.com/MyNS/1.0/' },
    WRITABLE      => 'string', # (default to string-type tags)
    MyStruct   => {
       Struct => {
         MyId => {Writable => 'integer'},
         JSON => {},
         Created => {Writable => 'date'}
       },
       List => 'Seq',
       Name => 'MyData',
    },
);

1;  #end


But when i add a new tag
exiftool -config .ExifTool_config -MyDataMyId+=1 -MyDataCreated+=2020:05:07 -MyDataJSON+="{\"a\":1}" img.jpg


but the problem is i see the XMP as <MyNS:JSON>{&quot;a&quot;:1}</MyNS:JSON>


Is there a way to make sure the json data is not encoded?

Phil Harvey

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