John Liu .NET

View Original

ForEach Property in #MicrosoftFlow JSON. With XPath? #microblog

I can't think of a way to do "ForEach Property Of JSON" in MicrosoftFlow or LogicApps - so I came up with this method that involves XPath.

Take example this JSON

See this content in the original post

I want to do ForEach over the properties, so I need a way to convert this into:

See this content in the original post

The usual suspects don't seem to work:

  • ForEach (only array)
  • Data Operations - Select (only array)
  • Array (wraps one object into array of one object)
  • CreateArray (wraps multiple objects into array)
  • Split - this could be used, but we'll have a hard time with nested JSON

Lets do XPath

XML objects must have one root element.  So let's wrap a root around our JSON

See this content in the original post

This next XPath splits each XML element under /root/ into a Nodeset (array of XML elements).

See this content in the original post

Data Operations - Select

for each XML node, select just the name, map this for each node

See this content in the original post

Result

See this content in the original post

I'm sure there'll be a better way one day.  But for now this will get me through.  I need this to be able to read nested JSON structures as part of my bigger plan.