I have reproduced in my environment and got expected results as below:
Input:
{
"foo.companies": {
"type": "Array",
"value": [{
"foo": ["123"]
},
{
"bar": ["135"]
}
]
}
}

Now In Design:

I have given hardcoded value like bar and foo(you have given you will get it dynamically and you can save dynamic value in a variable)
Then Parse Json:

Shema :
{
"properties": {
"foo.companies": {
"properties": {
"type": {
"type": "string"
},
"value": {
"items": {
"properties": {
"bar": {
"items": {
"type": "string"
},
"type": "array"
},
"foo": {
"items": {
"type": "string"
},
"type": "array"
}
},
"required": [],
"type": "object"
},
"type": "array"
}
},
"type": "object"
}
},
"type": "object"
}
Then got the values into a array variable and then initialized a empty variable to get the value at end:

Then in for each loop:

Then compose for seeing output purpose:
Output:
foo variable value is retrieved:

bar value is retrieved:

Code view:(For easy replicating the design)
{
"definition": {
"$schema": "https://schema.management.azure.com/providers/Microsoft.Logic/schemas/2016-06-01/workflowdefinition.json#",
"actions": {
"Compose": {
"inputs": "@variables('var3')",
"runAfter": {
"For_each": [
"Succeeded",
"Failed"
]
},
"type": "Compose"
},
"For_each": {
"actions": {
"Condition": {
"actions": {
"Append_to_string_variable": {
"inputs": {
"name": "var3",
"value": "@item()[variables('var1')][0]"
},
"runAfter": {},
"type": "AppendToStringVariable"
}
},
"expression": {
"and": [
{
"equals": [
"@items('For_each')",
"@items('For_each')"
]
}
]
},
"runAfter": {},
"type": "If"
}
},
"foreach": "@variables('var2')",
"runAfter": {
"Initialize_variable_3": [
"Succeeded"
]
},
"type": "Foreach"
},
"Initialize_variable": {
"inputs": {
"variables": [
{
"name": "var2",
"type": "array",
"value": "@body('Parse_JSON')?['foo.companies']?['value']"
}
]
},
"runAfter": {
"Parse_JSON": [
"Succeeded"
]
},
"type": "InitializeVariable"
},
"Initialize_variable_2": {
"inputs": {
"variables": [
{
"name": "var1",
"type": "string",
"value": "foo"
}
]
},
"runAfter": {},
"type": "InitializeVariable"
},
"Initialize_variable_3": {
"inputs": {
"variables": [
{
"name": "var3",
"type": "string"
}
]
},
"runAfter": {
"Initialize_variable": [
"Succeeded"
]
},
"type": "InitializeVariable"
},
"Parse_JSON": {
"inputs": {
"content": "@triggerBody()",
"schema": {
"properties": {
"foo.companies": {
"properties": {
"type": {
"type": "string"
},
"value": {
"items": {
"properties": {
"bar": {
"items": {
"type": "string"
},
"type": "array"
},
"foo": {
"items": {
"type": "string"
},
"type": "array"
}
},
"required": [],
"type": "object"
},
"type": "array"
}
},
"type": "object"
}
},
"type": "object"
}
},
"runAfter": {
"Initialize_variable_2": [
"Succeeded"
]
},
"type": "ParseJson"
}
},
"contentVersion": "1.0.0.0",
"outputs": {},
"parameters": {},
"triggers": {
"manual": {
"inputs": {
"schema": {}
},
"kind": "Http",
"type": "Request"
}
}
},
"parameters": {}
}