cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
New Member

Converting JSON output to array for For Each handling

A long time since I've done much coding and I'm struggling to understand some of the finer points of MS Flow and specifically handling JSON outputs.

 

I have a valid JSON response from an MDM platform that provides a list of devices registered to a user.

 

Some users will have an empty response (no devices), some a single, and some multiple devices.

 

I need to extract an array of items from JSON and act on each.  Specifically in the example below which shows a typical output for a user with an iOS and Windows Mobile device I need to extract the uuid from the device and pass this to another REST API call.

 

What I'm struggling to do is to create that array of uuid entries.

 

{
"totalCount": 0,
"messages": {
"message": "2 device(s) returned"
},
"devices": {
"device": [
{
"@id": "69307",
"uuid": "59141f88-7f05-4a2e-921a-7699748b9d5d",
"principal": "someone@somewhere",
"blockReason": 0,
"clientId": 1073811137,
"compliance": 0,
"countryCode": 44,
"countryId": 182,
"countryName": "United Kingdom",
"createdAt": "2018-07-17T14:12:01Z",
"currentPhoneNumber": "",
"details": [
{
"entry": [
{
"key": "safariForceFraudWarning",
"value": true
},
{
"key": "security_state",
"value": 1
},
{
"key": "Current MCC",
"value": 234
},
{
"key": "safariAcceptCookies",
"value": 2
},
{
"key": "allowCloudBackup",
"value": true
},
{
"key": "minLength",
"value": 4
},
{
"key": "SIM MCC",
"value": 234
},
{
"key": "allowFingerprintModification",
"value": true
},
{
"key": "ModemFirmwareVersion",
"value": "6.0.00"
},
{
"key": "maxGracePeriod",
"value": 15
},
{
"key": "allowAppInstallation",
"value": true
},
{
"key": "ratingTVShows",
"value": 1000
},
{
"key": "HardwareEncryptionCaps",
"value": 3
},
{
"key": "IsActivationLockEnabled",
"value": true
},
{
"key": "DataRoamingEnabled",
"value": true
},
{
"key": "OSVersion",
"value": "9.3.5"
},
{
"key": "allowDeviceNameModification",
"value": true
},
{
"key": "IsMDMLostModeEnabled",
"value": false
},
{
"key": "safariAllowJavaScript",
"value": true
},
{
"key": "device_id",
"value": ""
},
{
"key": "cookie",
"value": 123
},
{
"key": "allowUntrustedTLSPrompt",
"value": true
},
{
"key": "allowVideoConferencing",
"value": true
},
{
"key": "IsCloudBackupEnabled",
"value": false
},
{
"key": "allowKeyboardShortcuts",
"value": true
},
{
"key": "allowCloudDocumentSync",
"value": true
},
{
"key": "allowiTunes",
"value": true
},
{
"key": "forceAirDropUnmanaged",
"value": false
},
{
"key": "ratingApps",
"value": 1000
},
{
"key": "wifi_mac",
"value": ""
},
{
"key": "allowCloudKeyValueSync",
"value": true
},
{
"key": "allowAutomaticAppDownloads",
"value": true
},
{
"key": "processor_architecture",
"value": "ARM"
},
{
"key": "maxInactivity",
"value": 5
},
{
"key": "requireIdentifiersSettings",
"value": true
},
{
"key": "CarrierSettingsVersion",
"value": 24
},
{
"key": "BluetoothMAC",
"value": ""
},
{
"key": "pinHistory",
"value": 4
},
{
"key": "allowCloudPhotoLibrary",
"value": true
},
{
"key": "apnsToken",
"value": ""
},
{
"key": "system_version",
"value": "9.3.5"
},
{
"key": "SIM MNC",
"value": 10
},
{
"key": "Current MNC",
"value": 20
},
{
"key": "allowInAppPurchases",
"value": true
},
{
"key": "ActivationLockBypassCode",
"value": "Only generated for supervised devices."
},
{
"key": "SERIAL",
"value": ""
},
{
"key": "Battery Level",
"value": 1
},
{
"key": "SIMCarrierNetwork",
"value": ""
},
{
"key": "PasscodePresent",
"value": true
},
{
"key": "AvailableDeviceCapacity",
"value": 5.3999786376953125
},
{
"key": "allowVoiceDialing",
"value": true
},
{
"key": "os_version",
"value": "iPhone OS 9.3.5 (13G36)"
},
{
"key": "forceWatchWristDetection",
"value": false
},
{
"key": "prv_dpm_encryption_status",
"value": ""
},
{
"key": "EASDeviceIdentifier",
"value": ""
},
{
"key": "mdm_tos_accepted",
"value": true
},
{
"key": "free_storage_size_bytes",
"value": "5798182912.0000000000000000"
},
{
"key": "ratingMovies",
"value": 1000
},
{
"key": "Model",
"value": "MD242B"
},
{
"key": "PhoneNumber",
"value": "+"
},
{
"key": "iOSBackgroundStatus",
"value": 1
},
{
"key": "allowSafari",
"value": true
},
{
"key": "iPhone PRODUCT",
"value": "iPhone 4S"
},
{
"key": "DeviceName",
"value": ""
},
{
"key": "forceITunesStorePasswordEntry",
"value": false
},
{
"key": "ProductName",
"value": "iPhone4,1"
},
{
"key": "iTunesStoreAccountHash",
"value": ""
},
{
"key": "allowAutoCorrection",
"value": true
},
{
"key": "device_type",
"value": "GSM"
},
{
"key": "allowEnterpriseAppTrust",
"value": true
},
{
"key": "client_id",
"value": 1073763246
},
{
"key": "mode",
"value": 0
},
{
"key": "allowYouTube",
"value": true
},
{
"key": "total_storage_size_bytes",
"value": "29169532928.000000536870912"
},
{
"key": "allowPairedWatch",
"value": true
},
{
"key": "it_policy_result",
"value": 1
},
{
"key": "allowPhotoStream",
"value": true
},
{
"key": "platform_type",
"value": "iPhone"
},
{
"key": "allowNews",
"value": true
},
{
"key": "mtd_sync_time",
"value": ""
},
{
"key": "security_reason_code",
"value": "0x40000000"
},
{
"key": "Subscriber Carrier Network",
"value": "O2"
},
{
"key": "osUpdateStatus",
"value": "Unavailable"
},
{
"key": "ModelName",
"value": "iPhone"
},
{
"key": "Client_build_date",
"value": "Jun 28 2018 18:33:23"
},
{
"key": "IsDoNotDisturbInEffect",
"value": false
},
{
"key": "ImeiOrMeid",
"value": "01 305900 716590 6"
},
{
"key": "iPhone VERSION",
"value": "13G36"
},
{
"key": "mtd_status",
"value": "N/A"
},
{
"key": "PersonalHotspotEnabled",
"value": false
},
{
"key": "SerialNumber",
"value": ""
},
{
"key": "allowGlobalBackgroundFetchWhenRoaming",
"value": true
},
{
"key": "tosaccepted",
"value": true
},
{
"key": "iTunesStoreAccountIsActive",
"value": true
},
{
"key": "PasscodeIsCompliant",
"value": true
},
{
"key": "iPhone UDID",
"value": ""
},
{
"key": "safariAllowAutoFill",
"value": true
},
{
"key": "Voice Roaming Enabled",
"value": "N/A"
},
{
"key": "device_model",
"value": "iPhone 4S"
},
{
"key": "iPhone ICCID",
"value": ""
},
{
"key": "allowCamera",
"value": true
},
{
"key": "allowWallpaperModification",
"value": true
},
{
"key": "allowMultiplayerGaming",
"value": true
},
{
"key": "allowPredictiveKeyboard",
"value": true
},
{
"key": "allowExplicitContent",
"value": true
},
{
"key": "locale",
"value": "en-GB"
},
{
"key": "WiFiMAC",
"value": ""
},
{
"key": "platform",
"value": "iphone"
},
{
"key": "device_manufacturer",
"value": "Apple"
},
{
"key": "IsDEPDevice",
"value": false
},
{
"key": "DeviceCapacity",
"value": 27.166244506835938
},
{
"key": "safariPlugins",
"value": true
},
{
"key": "platform_flags",
"value": "0x38"
},
{
"key": "forceEncryptedBackup",
"value": true
},
{
"key": "forceFIPSVerification",
"value": false
},
{
"key": "platform_name",
"value": "iPhone"
},
{
"key": "battery_life",
"value": -100
},
{
"key": "BuildVersion",
"value": "13G36"
},
{
"key": "udid",
"value": ""
},
{
"key": "regUuid",
"value": ""
},
{
"key": "allowSpellCheck",
"value": true
},
{
"key": "client_name",
"value": "com.mobileiron.phoneatwork"
},
{
"key": "allowDefinitionLookup",
"value": true
},
{
"key": "iPhone IMEI",
"value": ""
},
{
"key": "maxPINAgeInDays",
"value": 90
},
{
"key": "CellularTechnology",
"value": "GSM"
},
{
"key": "system_name",
"value": "iPhone OS"
},
{
"key": "mdm_tos_accepted_date",
"value": 1531836824996
},
{
"key": "ip_address",
"value": "192.168.1.7"
},
{
"key": "allowUIAppInstallation",
"value": true
},
{
"key": "IsDeviceLocatorServiceEnabled",
"value": true
},
{
"key": "Supervised",
"value": false
},
{
"key": "allowPasscodeModification",
"value": true
},
{
"key": "allowScreenShot",
"value": true
},
{
"key": "AwaitingConfiguration",
"value": false
},
{
"key": "safariAllowPopups",
"value": true
},
{
"key": "PasscodeIsCompliantWithProfiles",
"value": true
},
{
"key": "Client_version",
"value": "10.0.1"
},
{
"key": "vpn_ip_address",
"value": "(null)"
}
]
}
],
"deviceCount": 0,
"easLastSyncAttempt": "2018-07-18T21:50:13Z",
"easUuid": "0",
"emailAddress": "uk",
"employeeOwned": true,
"homeOperator": "O2 (UK)",
"languageCountryId": 182,
"languageId": 1,
"lastConnectedAt": "2018-07-18T21:20:01Z",
"manufacturer": "Apple",
"mdmManaged": true,
"mdmProfileUrlId": 1,
"model": "iPhone 4S",
"name": "",
"notifyUser": true,
"operator": "O2 (UK)",
"operatorId": 2707,
"phoneNumber": "PDA 2",
"platform": "iOS 9.3",
"quarantinedStatus": 0,
"regCount": 0,
"regType": "DEFAULT",
"registeredAt": "2018-07-17T14:13:45Z",
"status": "ACTIVE",
"statusCode": 97,
"TLVVersion": 1,
"userDisplayName": ")",
"userFirstName": "",
"userId": 10510,
"userLastName": "",
"userSource": 68,
"userUUID": "",
"wipeReason": 0,
"iPhoneVersion": "13G36"
},
{
"@id": "69385",
"uuid": "9f77c9f1-f9b3-4464-a5cc-9f0ec36dd875",
"principal": "",
"blockReason": 0,
"clientId": 1073811215,
"compliance": 0,
"countryCode": 0,
"createdAt": "2018-07-19T08:36:12Z",
"currentPhoneNumber": "PDA 4",
"details": [
{
"entry": [
{
"key": "prv_microsoft_store_uri",
"value": "on"
},
{
"key": "prv_manual_email_setup_uri",
"value": "on"
},
{
"key": "prv_password_minimum_symbols",
"value": 1
},
{
"key": "prv_sdcard",
"value": "on"
},
{
"key": "prv_max_failed_attempts",
"value": 10
},
{
"key": "wifi_mac_addr",
"value": ""
},
{
"key": "prv_cortana",
"value": "on"
},
{
"key": "prv_bluetooth",
"value": "on"
},
{
"key": "prv_wifi",
"value": "on"
},
{
"key": "prv_internet_sharing_uri",
"value": "on"
},
{
"key": "prv_password",
"value": "on"
},
{
"key": "longitude",
"value":
},
{
"key": "prv_allow_action_center_notifications",
"value": "on"
},
{
"key": "wp_management_service_address",
"value": ""
},
{
"key": "device_id",
"value": ""
},
{
"key": "poll_number_of_second_retries",
"value": 0
},
{
"key": "wp_processor_arch",
"value": 5
},
{
"key": "prv_win_security_allow_all_trusted_apps",
"value": 1
},
{
"key": "wp_os_platform",
"value": "Windows Phone"
},
{
"key": "wp_device_name",
"value": "Windows phone"
},
{
"key": "prv_let_apps_run_in_background",
"value": "User Controlled"
},
{
"key": "edp_report_captured_at",
"value": "2018-07-19T08:49:06.640Z"
},
{
"key": "prv_password_type",
"value": 1
},
{
"key": "prv_vpn_while_roaming_uri",
"value": "on"
},
{
"key": "prv_search_to_use_location",
"value": "on"
},
{
"key": "edp_status",
"value": 0
},
{
"key": "prv_roamingdata",
"value": "on"
},
{
"key": "prv_win_appsatwork_server",
"value": ""
},
{
"key": "prv_win_appsatwork_certificate_authentication_enabled",
"value": false
},
{
"key": "wns_channel_URL",
"value": ""
},
{
"key": "prv_return_without_password",
"value": "on"
},
{
"key": "prv_browser",
"value": "on"
},
{
"key": "dm_client_version",
"value": 1.3
},
{
"key": "device_model",
"value": "Lumia 550"
},
{
"key": "poll_interval_for_remaining_of_retries",
"value": 0
},
{
"key": "prv_max_idle_time",
"value": 15
},
{
"key": "prv_allow_developer_unlock",
"value": "on"
},
{
"key": "latitude",
"value": 52.08225
},
{
"key": "prv_screencapture",
"value": "on"
},
{
"key": "wp_device_instance_service_imei",
"value": ""
},
{
"key": "prv_password_expiration_timeout",
"value": 90
},
{
"key": "prv_win_appsatwork_email",
"value": ""
},
{
"key": "prv_allow_browser_password_manager",
"value": "on"
},
{
"key": "prv_usbmassstorage",
"value": "on"
},
{
"key": "prv_sd_encryption",
"value": "unsupported"
},
{
"key": "imsi",
"value": ""
},
{
"key": "prv_password_length",
"value": 4
},
{
"key": "total_storage_size",
"value": 7456000000
},
{
"key": "prv_copypaste",
"value": "on"
},
{
"key": "locale",
"value": "en-GB"
},
{
"key": "prv_microsoft_account",
"value": "on"
},
{
"key": "prv_win_appsatwork_install",
"value": ""
},
{
"key": "prv_nfc",
"value": "on"
},
{
"key": "device_manufacturer",
"value": "MicrosoftMDG"
},
{
"key": "win10_antivirus_signature_status",
"value": 2
},
{
"key": "win10_antivirus_status",
"value": 4
},
{
"key": "location_last_captured_at",
"value":
},
{
"key": "wp_firmware_version",
"value": "01078.00042.16352.50009"
},
{
"key": "current_operator",
"value": "000-88"
},
{
"key": "prv_password_allow_simple",
"value": 1
},
{
"key": "wp_processor_type",
"value": 0
},
{
"key": "wp_phone",
"value": true
},
{
"key": "total_ram_size",
"value": 1073741824
},
{
"key": "prv_wifi_offloading_uri",
"value": "on"
},
{
"key": "battery_life",
"value": 69
},
{
"key": "win10_os_edition",
"value": 104
},
{
"key": "prv_camera",
"value": "on"
},
{
"key": "prv_device_encryption",
"value": "on"
},
{
"key": "prv_profile_roaming",
"value": "on"
},
{
"key": "os_version",
"value": "10.0.15254.490"
},
{
"key": "poll_number_of_first_retries",
"value": 3
},
{
"key": "wp_ent_device_name",
"value": ""
},
{
"key": "prv_password_history_length",
"value": 4
},
{
"key": "ip_address",
"value": "82.11.98.157"
},
{
"key": "prv_retrieve_health_certificate",
"value": 0
},
{
"key": "prv_wp_allow_manual_mdm_unenrollment",
"value": "on"
},
{
"key": "wp_exchange_id",
"value": ""
},
{
"key": "wp_resolution",
"value": "720x1280"
},
{
"key": "prv_telemetry",
"value": "full"
},
{
"key": "prv_gps",
"value": "on"
},
{
"key": "prv_wp_allow_user_to_reset_phone",
"value": "on"
},
{
"key": "wp_local_time",
"value": "2018-07-19T09:49:01.0000601+01:00"
},
{
"key": "poll_interval_for_first_set_of_retries",
"value": 3
},
{
"key": "prv_win_appsatwork_device_id",
"value": ""
},
{
"key": "prv_manual_wifi_setup",
"value": "on"
},
{
"key": "prv_voice_recording",
"value": "on"
},
{
"key": "imei",
"value": ""
},
{
"key": "prv_manual_root_cert_installation",
"value": "on"
},
{
"key": "wp_radio_swv",
"value": "10c56.00030.0001"
},
{
"key": "wp_hardware_version",
"value": "3.0.0.0"
},
{
"key": "poll_interval_for_second_set_of_retries",
"value": 60
},
{
"key": "poll_number_of_remaining_retries",
"value": 0
}
]
}
],
"deviceCount": 0,
"easLastSyncAttempt": "1970-01-01T00:00:00Z",
"easUuid": "",
"emailAddress": "",
"employeeOwned": true,
"homeOperator": "PDA",
"languageCountryId": 183,
"languageId": 1,
"lastConnectedAt": "2018-07-19T08:49:12Z",
"manufacturer": "MicrosoftMDG",
"mdmManaged": false,
"model": "Lumia 550",
"name": "",
"notifyUser": true,
"operator": "PDA",
"phoneNumber": "PDA 4",
"platform": "Windows 10",
"quarantinedStatus": 0,
"regCount": 0,
"regType": "DEFAULT",
"registeredAt": "2018-07-19T08:37:25.817Z",
"status": "ACTIVE",
"statusCode": 97,
"TLVVersion": 1,
"userDisplayName": "",
"userFirstName": "",
"userId": 10510,
"userLastName": "",
"userSource": 68,
"userUUID": "",
"wipeReason": 0
}
]
}
}

2 REPLIES 2
Highlighted
Community Support
Community Support

Re: Converting JSON output to array for For Each handling

Hi @englishrobs,

 

Please try to use the action Parse JSON. By using this action, it will evaluate the content against the schema. This means that you can use the different fields you defined in the schema throughout the rest of your workflow as a dynamic content.

 

More details about Parse JSON, please check the doc at here:

https://flow.microsoft.com/en-us/blog/five-services-json-http/

 

 

Best regards,

Mabel Mao

Community Support Team _ Mabel Mao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Highlighted
New Member

Re: Converting JSON output to array for For Each handling

That's exactly what I have been using but unfortunately due to the complexity of the JSON structure the automatic nature of the Parse JSON capability in Flow simply couldn't cope.

 

I've since created a custom API call that returns a much simpler JSON output object that works much better.  I've had some further issues like the parser not coping with null objects but some hand editing of the JSON schema definition fixes that.

Helpful resources

Announcements
firstImage

Super User Program Update

Three Super User rank tiers have been launched!

firstImage

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

firstImage

New & Improved Power Automate Community Cookbook

We've updated and improved the layout and uploading format of the Power Automate Cookbook!

thirdimage

Power Automate Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

Top Solution Authors
Users online (9,074)