cancel
Showing results forย 
Search instead forย 
Did you mean:ย 

How to convert linkedHashMap to list / json object

Satyanarayana
New Contributor II

Hi Team,

I have an input json in linkedHashMap in below format:

[
{
โ€œPathโ€: โ€œ/OrgName/sharedโ€,
โ€œsubject_typeโ€: [
โ€œGROUPโ€,
โ€œGROUPโ€,
โ€œGROUPโ€,
โ€œUSERโ€
],
โ€œsubjectโ€: [
โ€œOperationsโ€,
โ€œadminsโ€,
โ€œArchitectsโ€,
โ€œxyz@xyz.comโ€
],
โ€œpermsโ€: [
[
โ€œRโ€,
โ€œXโ€,
โ€œWโ€
],
[
โ€œRโ€,
โ€œXโ€
],
[
โ€œRโ€,
โ€œXโ€
],
[
โ€œRโ€,
โ€œXโ€
]
]
},
{
โ€œPathโ€: โ€œ/OrgName/shared2โ€,
โ€œsubject_typeโ€: [
โ€œGROUPโ€,
โ€œGROUPโ€,
โ€œGROUPโ€,
โ€œUSERโ€
],
โ€œsubjectโ€: [
โ€œOperationsโ€,
โ€œadminsโ€,
โ€œArchitectsโ€,
โ€œabc@abc.comโ€
],
โ€œpermsโ€: [
[
โ€œRโ€,
โ€œXโ€,
โ€œWโ€
],
[
โ€œRโ€,
โ€œXโ€
],
[
โ€œRโ€,
โ€œXโ€
],
[
โ€œRโ€,
โ€œXโ€
]
]
}
]

My requirement is to map the respective fields and need them in a file as below:

{
{ โ€œPathโ€: โ€œ/OrgName/sharedโ€,
โ€œsubject_typeโ€:โ€œGROUPโ€,
โ€œsubjectโ€:โ€œOperationsโ€
โ€œpermsโ€: [
โ€œRโ€,
โ€œXโ€,
โ€œWโ€
]
},
{ โ€œPathโ€: โ€œ/OrgName/sharedโ€,
โ€œsubject_typeโ€:โ€œGROUPโ€,
โ€œsubjectโ€:โ€œadminsโ€
โ€œpermsโ€:
[
โ€œRโ€,
โ€œXโ€
]

	},
	{ "Path": "/OrgName/shared",
    "subject_type":"GROUP",
	"subject":"Architects"
	"perms": 
            [
            "R",
            "X"
        ]
        
	},
	{ "Path": "/OrgName/shared",
    "subject_type":"user",
	"subject":"xyz@xyz.com"
	"perms": 
            [
            "R",
            "X"
        ]
        
	}
	}

can it be achieved using any inbuilt snaps or should we go for a script? Any script snippets is appreciated.

Regards,
Satya

1 ACCEPTED SOLUTION

Anil
New Contributor III

Hi Satya,

Please find the attached pipeline for the solution.

Regards,
Anil

Convert_LinkedHashMap_to_list_2019_12_31.slp (6.7 KB)

View solution in original post

4 REPLIES 4

cstewart
Former Employee

Please take a look at the sl.zip function.

Many thanks for the reply. This resolved my issue.

Anil
New Contributor III

Hi Satya,

Please find the attached pipeline for the solution.

Regards,
Anil

Convert_LinkedHashMap_to_list_2019_12_31.slp (6.7 KB)

Satyanarayana
New Contributor II

Hello Anil,

The pipeline exactly matches my requirement. Thank you for your time on this.

Regards,
Satya