Having problems with your account or logging in?
A lot of changes are happening in the community right now. Some may affect you. READ MORE HERE
steven Frequent Contributor.
Frequent Contributor.
188 views

how to set location path / trigger node for nested json parser?

Hi I have a problem getting an element from a nested JSON.

I can get every field exept for the ones enclosed in the Event {..} element

This is the JSON and I want to have the info field tokenized. How should I set the location for the info field?

I tried to test a relative path and a absolute path but neither work on the location. All other fields outside the Event { } element are fetched perfectly.

 Sample event:

{
  "response": {
    "Attribute": [
       {
        "id": "12345678",
        "event_id": "1234",
        "category": "Payload delivery",
        "type": "md5",
        "to_ids": true,
        "uuid": "5eaf36e8-80f8-407e-0d8-4c310d950e0f",
        "timestamp": "1554723814",
        "distribution": "5",
        "sharing_group_id": "0",
        "comment": "Analyst comments here",
        "deleted": false,
        "disable_correlation": false,
        "object_id": "0",
        "object_relation": null,
        "value": "9a7d82ba55216defc2d4131b6c453f02",
        "Event": {
          "org_id": "1",
          "distribution": "3",
          "id": "1630",
          "info": "bad thuff happening with this file",
          "orgc_id": "1",
          "uuid": "5eaf36e8-80f8-407e-0d8-4c310d950e0f"

         }
      },
   {.... next message with same structure... }
 ]
 }
}

 

 

trigger.node.location=/response/Attribute

# These tokens are fine

token[0].name=id
token[0].type=String
token[0].location=id

token[1].name=event_id
token[1].type=String
token[1].location=event_id

token[2].name=category
token[2].type=String
token[2].location=category

....

# This one doesn't pickup...

token[16].name=event_info
token[16].type=string
token[16].location=Event/info

how should I set the location for the Event/info field??

thx,

/Steven

 

Labels (1)
0 Likes
7 Replies
Highlighted
Knowledge Partner
Knowledge Partner

Re: how to set location path / trigger node for nested json parser?

Can you try the following? Attribute and the Event part are on the same level, so you need to go upper level with "../"

token[16].name=event_info
token[16].type=string
token[16].location=../Event/info

------------------------------------
Please use the Like button below, if you find this post useful or mark it as an accepted solution if it resolves your issue.
0 Likes
steven Frequent Contributor.
Frequent Contributor.

Re: how to set location path / trigger node for nested json parser?

Actually no, Event falls under the same level as alle the other fields, I tried your suggestion but no result. All the fields are under the /response/Attribute collection [ { } ] The only difference with Event/info is that info is a subfield of Event. I can't seem to get any of the subfields in Event { }. /steven
0 Likes
Knowledge Partner
Knowledge Partner

Re: how to set location path / trigger node for nested json parser?

Sorry for the misunderstanding. I think I've figured it out now. It seems that the event section is not an array; that's why you can't tokenize the event/info part. My suggestion would be:
Tokenize the Event section as a whole. Then create a map file and extract the relevant information from it by using __regexToken or __multilineRegexToken

token[16].name=event_info
token[16].type=string
token[16].location=Event

 

------------------------------------
Please use the Like button below, if you find this post useful or mark it as an accepted solution if it resolves your issue.
0 Likes
steven Frequent Contributor.
Frequent Contributor.

Re: how to set location path / trigger node for nested json parser?

hi @mr_ergene ,

unfortunately that doesnt work either. It looks like it is impossible to get the value of nested subobjects within an Array  [ ]

Array [
{ object1: value1,
   object2: value2,
  { nestedObject1: "value",
    nestedObject2:"value "
 }
}
]

0 Likes
Knowledge Partner
Knowledge Partner

Re: how to set location path / trigger node for nested json parser?

Can you attach an original json file if possible? 

------------------------------------
Please use the Like button below, if you find this post useful or mark it as an accepted solution if it resolves your issue.
0 Likes
steven Frequent Contributor.
Frequent Contributor.

Re: how to set location path / trigger node for nested json parser?

Here you go:

 

0 Likes
Knowledge Partner
Knowledge Partner

Re: how to set location path / trigger node for nested json parser?

I'm getting errors about close markers and trigger locations with the file.

------------------------------------
Please use the Like button below, if you find this post useful or mark it as an accepted solution if it resolves your issue.
0 Likes
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.