Extracting resname/IDs in JSON

21 views
Skip to first unread message

Manuel Souto Pico

unread,
Aug 29, 2024, 1:09:59 PM8/29/24
to okapi-users
Dear all, 

I have a JSON file with a structure like so:

[
    {
        "createdAt": "2024-05-09T14:21:58.064Z",
        "updatedAt": "2024-05-09T14:21:58.064Z",
        "uuid": "cfa2879c-7535-4ab1-9fe7-e94e58763459",
        "currentVersion": {
            "title": "bar",
            "body": [
                {
                    "type": "Text",
                    "text": "foo",
                    "uuid": "986c08b5-be88-464c-abcc-d7358a09c796"
                },
                {
                    "type": "Text",
                    "text": "qux",
                    "uuid": "3d735193-fba3-4749-a56b-5755b130834d"
                }
            ]
        }
    }
]

My fprm file (attached) has idRules=uuid|currentVersion.body.uuid

I'm trying to extract "uuid": "986c08b5-be88-464c-abcc-d7358a09c796" (currentVersion.body.uuid) as the ID for "text": "foo" and "uuid": "cfa2879c-7535-4ab1-9fe7-e94e58763459" as the ID for "title": "bar", but I get the first one extracted for both. 

In other words, the IDs associated with the extracted segments are (from bottom to top): 

qux: 3d735193-fba3-4749-a56b-5755b130834d <- CORRECT
foo: 986c08b5-be88-464c-abcc-d7358a09c796 <- CORRECT
bar: 986c08b5-be88-464c-abcc-d7358a09c796 <- INCORRECT!

Expected, instead: 

qux: 3d735193-fba3-4749-a56b-5755b130834d
foo: 986c08b5-be88-464c-abcc-d7358a09c796
bar: cfa2879c-7535-4ab1-9fe7-e94e58763459 <-- OK

Is there a way to achieve what I want?

I think jSON does not have an equivalent to XML's XPath, but is there any way to match an ID key relative to the text key? 

Thanks a lot.
Cheers, Manuel


okf_json@ysc-uuid-test.fprm

Manuel Souto Pico

unread,
Sep 23, 2024, 5:06:28 PM9/23/24
to okapi-users
Dear all, 

Any tip to put me in the right direction would be greatly appreciated. 

Thanks! 
Cheers, Manuel
Reply all
Reply to author
Forward
0 new messages