How to parse JSON response with multiple "arrays"

jeffD1
Tera Contributor

I am trying to parse a JSON response from a rest step in flow designer. I can parse the entire body, but I need to iterate through the response and find values within a certain array and return those values for use in populating an import set row table. The response has multiple arrays and I am unsure of how to correctly parse the response.

 

The structure is below:

 

{"exportId":"value",
"instance":"value",
"content":[
	{
		"file":{
			"header":{
				"id":"value",
				"name":"value",
				"description":"value",
				"version":"value",
				"exportID":"value",
				"exportInstance":"value",
				"extractionMode":"value",
				"extractionDate":"value"},
			"body":{
				"records":[
					{
						"id":1,
						"code":"value",
						"name":"value",
						"parent_department":null,
						"operating_center":"value",
						"isActive":true,
						"department_manager":{
							"linked_record":{
								"user_ID":"value",
								"general_informations":{
									"first_Name":"value",
									"last_Name":"value",
									"full_Name":"value"
								},
								"technicalData":{
									"lastUser":"value",
									"creationTime":"value",
									"lastTime":"value",
									"primaryKey":"value",
									"foreignKey":"value",
									"linkedTable":"value"
								}
							}
						},
						"technicalData":{
							"lastUser":"value",
							"creationTime":"value",
							"lastTime":"value",
							"primaryKey":"1"
						}
					},
					{
						"id":2,
						"code":"value",
						"name":"value",
						"parent_department":null,
						"operating_center":"value",
						"isActive":true,
						"department_manager":{
							"linked_record":{
								"user_ID":"value",
								"general_informations":{
									"first_Name":"value",
									"last_Name":"value",
									"full_Name":"value"
								},
								"technicalData":{
									"lastUser":"value",
									"creationTime":"value",
									"lastTime":"value",
									"primaryKey":"value",
									"foreignKey":"value",
									"linkedTable":"value"
								}
							}
						},
						"technicalData":{
							"lastUser":"value",
							"creationTime":"value",
							"lastTime":"value",
							"primaryKey":"1"
						}
					},
					]
				},
			"footer":{
				"nb_records":200
			}
		}
	}
],
"pagination":{
	"nextPage":"URL to Second Page"
}
}

What I need to know is how to get to the "Records" array and grab the values from the value pairs there, including the specific user_id within the linked_record array under the department_manager array.

 

How would I gather the data correctly? 

1 ACCEPTED SOLUTION

-O-
Kilo Patron
Kilo Patron

If you have the JSON parser step licensed, you can use it to obtain an Action that has the array as output with all the keys as data pills, as described in blog post Paris IntegrationHub JSON Parser and Payload Builder.

If you don't have that step licensed, you need to add a Script step which on one hand has the array and its fields defined and on the other return and sets that output.

Something like this:

1.png

Of course this is just an example, you would also have the REST step before the Script one and you would have inputs for the Script step that would allow passing in the REST response body and the Action itself would have an output defined that would be the same as the Script step output.

View solution in original post

1 REPLY 1

-O-
Kilo Patron
Kilo Patron

If you have the JSON parser step licensed, you can use it to obtain an Action that has the array as output with all the keys as data pills, as described in blog post Paris IntegrationHub JSON Parser and Payload Builder.

If you don't have that step licensed, you need to add a Script step which on one hand has the array and its fields defined and on the other return and sets that output.

Something like this:

1.png

Of course this is just an example, you would also have the REST step before the Script one and you would have inputs for the Script step that would allow passing in the REST response body and the Action itself would have an output defined that would be the same as the Script step output.