Richa_T Respected Contributor.
Respected Contributor.
497 views

Pick specific fields in Result

Hi,

I get JSON output in below format in a operation and I want to pick some specific fields from the below output like> "vlanid": 1020, "interface": "reth0" and whether its under OMA or RTP (these fields occur number of times and I want to pick all). I tried using Regex but i think using that I can only pick a specific fields and not everything I want. can this be done? Any suggestions

"dcsuccess": [
{
"OMA": {
"asn": 395008,
"bu": "PI",
"connection-id": "dxcon-fhc52y0w",
"env": "dev",
"interface": "reth0",
"irladdr": "137.199.229.189/30",
"peeraddr": "137.199.229.190",
"vgw-id": "vgw-01ebf9289fee3bc0c",
"vif-name": "PI-DEV-OMA-1020",
"vlan": 1020,
"vlanid": 1020,
"vpcnet": "10.229.168.0/22"
},
"RTP": {
"asn": 395013,
"bu": "PI",
"connection-id": "dxcon-fgu70qjk",
"env": "dev",
"interface": "reth0",
"irladdr": "137.199.245.189/30",
"peeraddr": "137.199.245.190",
"vgw-id": "vgw-01ebf9289fee3bc0c",
"vif-name": "PI-DEV-RTP-1020",
"vlan": 1020,
"vlanid": 1020,
"vpcnet": "10.229.168.0/22"
},
"bu": "PI",
"env": "dev",
"master-account": "427812497737",
"owneraccount": "443749199071",
"region": "us-east-1",
"transactionId": "152",
"vgw-id": "vgw-01ebf9289fee3bc0c",
"vif": {
"OMA": {
"state": "pending",
"vif-id": "dxvif-fhaalvsk"
},
"RTP": {
"state": "pending",
"vif-id": "dxvif-fhaouzsq"
}
},

Thanks!

0 Likes
4 Replies
Trusted Contributor.. KedarB Trusted Contributor..
Trusted Contributor..

Re: Pick specific fields in Result

Hey Richa

There are multiple ways to accomplish this.

1) Using Filters (create multiple Customer filters)

2) Parse Json operation

3) Convert Json to XML and filter out required details.

4) Writing Javacript scriplet to filter required details. (Using scriplet)

1st and last options are very subjective and may fail if your output Json response changes.

Using Json or XML option, i believe will be accurate.

 

Regards,

-Kedar

Richa_T Respected Contributor.
Respected Contributor.

Re: Pick specific fields in Result

Thanks for your response Kedar.

How can I convert JSON to XML , is there any operation to do that?

0 Likes
Bridges Respected Contributor.
Respected Contributor.

Re: Pick specific fields in Result

 Look in the base content pack > Utility Operations > Containers > JSON

It will contain JSON operations that you can use, including Convert JSON to XML

 

0 Likes
Richa_T Respected Contributor.
Respected Contributor.

Re: Pick specific fields in Result

Hi,

I was looking atJSON path operation, does  json input has a limit because I noticed that i am unable to copy my whole json as a input, is there any alternative if I have a huge json?

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.