JSON Transformer Move Node Name

Hello,

I have JSON that looks like this:

{
  "188761259" : {
    "correlation : "None",
    "is_active" : false,
    "last_activity_at_ms" : 1643803819000
  }
}

I need to get the “188761259” Any ideas?

I’m sure it can be done with the right query in a JSON Path node, but I couldn’t figure it out. I found some JavaScript solutions on Stackoverflow, but those obviously don’t work here.
I’m more of an XML guy anyway. So I transformed your JSON to an XML, and queried the parent name.
If you want it to be a different data type, you can edit the XPath query and select any suitable type there.
JSON transformer
JSON transformer.knwf (19.5 KB)

Hi @nxfxcom , just retrieve the paths instead of the values in your JSON Path like this:

This will return all the paths of the elements in a list:

Then ungroup the list:
image

You can take any of them, probably the first one is the easiest to deal with.

The whole thing looks like this:
image

Then do some string manipulation to clean it up. After clean up, results are as follows:
image

Final workflow looks like this:
image

Here’s the workflow: Get JSON root value.knwf (14.3 KB)

2 Likes

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.