Update existing items via JSON-LD import

I’m trying to create a workflow between Tropy and R by importing and exporting via JSON-LD. The import works perfectly (thanks to advice on other threads such as here and here).

But is there a way to update an existing item? At the moment, it looks like importing an item duplicates it, rather than replaces/overrides the metadata for the existing item. I have tried with relative and absolute paths to see if Tropy recognises the item, as well as keeping the title and/or the identifier fields identical. Is this expected behaviour? Any thoughts?

The idea is to export an item, alter the JSON-LD in another tool, then re-import to update the original items with the changes, right?

This is interesting because we’re currently designing a new plugin hook to alter existing items with pretty much the same idea: plugin receives the JSON-LD, manipulates it, returns JSON-LD, Tropy figures out how the alterations to the JSON-LD affect the original item and applies the changes to it.

In any case, currently when paste/import JSON-LD you will always get a new item. What you can do is merge the old item into the original one. For example:

  1. Select an item and export it (or copy it and paste the JSON-LD somewhere)
  2. Manipulate the JSON-LD
  3. Import the altered JSON-LD
  4. Drag the original item on the newly imported item to merge them
  5. Remove the duplicate photos in the merged item

Note that when merging items the order is important. For most purposes I think you will want to drag the original item over the new one, to merge the old item into the changed one.

Thanks @inukshuk! Yes that is exactly what I wanted to do; the idea is to be able to look at Tropy annotations in RStudio to explore/quantify them, and then potentially import the data back into Tropy with, for example, a new tag attached to specific subsets.

I’ll be keeping my eyes open for the plugin and will merge individual items until then.

1 Like