Parsing JSON to see specific Key & Value

Hi,

I am setting up a project with JSON files to be translated.

I am trying to parse it to enhance workflow.
The structure of the JSON files are as follows:

Screenshot of JSON file in Trados Studio with text highlighted in green indicating translatable content and orange highlighting for 'slug' field.

With "$..content.*" I get everything that is highlighted in green (which is what needs to be translated). The file looks like this in Trados:

Trados Studio interface showing a list of strings with checkboxes, and a question mark indicating confusion about which string is the 'slug'.

I have been asked to translate the values of "name", "seotitle", "seodescription" and "content". The "slug" (highlighted in orange) is only to be translated if there is a color in it. For example, "thisisastring" should be left as is, but if it is "thisisastring-black", "black" should be translated.

The problem is, often name, seotitle, seodescription and slug are exactly identical. This means that it will be very easy to translate the value of "slug" by mistake, thinking it's one of the value of one of the other keys. The files are also different. Some files don't have slugs, some don't have seo descriptions. So I can't predict that it's always the fourth segment or something similar.

Is there a way for me to use both "$..content.*" and another expression to show me when the segment is actually a "slug"? Optimally the slug segment would say "slug": "thisisastring" (or something similar) so I always know which ones they are.


Thank you kindly for helping!
Have a nice day.



Generated Image Alt-Text
[edited by: Trados AI at 1:58 AM (GMT 0) on 29 Feb 2024]
emoji
Parents Reply Children
  • Naoko, all files are structured as the file in the screenshot. "Slug" does not appear in any other structure. However, please note that I am referring to "content" that is the parent of "slug". I know it's slightly confusing that there is also a sibling to "slug" called "content". In other words, I need to translate all the values of the parent called "content", but I need to distinguish "slug" from the other children of "content", since "slug" will be considered partly as a non-translatable.

    I found this very helpful website where I could try different paths http://jsonpath.com/ . It seems that $..slug and $..content.slug does the same thing. 

    And with the answer you gave me before, I could set "slug" as a LBL and thus distinguish it from the other content. 

    Thank you so much!