cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
thomas1992UK
Frequent Visitor

Parse JSON Error

Hi All,

 

I'm having a few issues with parsing a JSON response from a HTTP call.

I receive the JSON response and I try to parse this response, I am having trouble extracting the data I need from the response.

 

Example Response:

 

{
    "results": {
        "timesheets": {
            "153480": {
                "id"153480,
                "user_id"76985,
                "jobcode_id"863233,
                "start""",
                "end""",
                "duration"25200,
                "date""2020-04-06",
                "tz"12,
                "tz_str""Pacific/Auckland",
                "type""manual",
                "location""TSheets web",
                "on_the_clock"false,
                "locked"0,
                "notes""",
                "last_modified""2020-04-13T23:45:22+00:00",
                "customfields""",
                "attached_files": [],
                "created_by_user_id"74317
            },
            "153482": {
                "id"153482,
                "user_id"76985,
                "jobcode_id"863233,
                "start""",
                "end""",
                "duration"18000,
                "date""2020-04-07",
                "tz"12,
                "tz_str""Pacific/Auckland",
                "type""manual",
                "location""TSheets web",
                "on_the_clock"false,
                "locked"0,
                "notes""",
                "last_modified""2020-04-13T23:45:50+00:00",
                "customfields""",
                "attached_files": [],
                "created_by_user_id"74317
            },
            "153484": {
                "id"153484,
                "user_id"76985,
                "jobcode_id"863233,
                "start""",
                "end""",
                "duration"21600,
                "date""2020-04-11",
                "tz"12,
                "tz_str""Pacific/Auckland",
                "type""manual",
                "location""TSheets web",
                "on_the_clock"false,
                "locked"0,
                "notes""",
                "last_modified""2020-04-13T23:45:50+00:00",
                "customfields""",
                "attached_files": [],
                "created_by_user_id"74317
            }
        }
    }
 
I need to iterate through the response and get the number value where all the data is:
E.g. Data I need:
   "153484": {
                "id"
The number value and the ID for each response, my flow is below. Any help appreciated:
 
Current Schema:
{
  "type""object",
  "properties": {
    "results": {
      "type""object",
      "properties": {
        "timesheets": {
          "type""object",
          "properties": {
            "day_id": {
              "type""object",
              "properties": {
                "id": {
                  "type""integer"
                },
                "user_id": {
                  "type""integer"
                },
                "jobcode_id": {
                  "type""integer"
                },
                "start": {
                  "type""string"
                },
                "end": {
                  "type""string"
                },
                "duration": {
                  "type""integer"
                },
                "date": {
                  "type""string"
                },
                "tz": {
                  "type""integer"
                },
                "tz_str": {
                  "type""string"
                },
                "type": {
                  "type""string"
                },
                "location": {
                  "type""string"
                },
                "on_the_clock": {
                  "type""boolean"
                },
                "locked": {
                  "type""integer"
                },
                "notes": {
                  "type""string"
                },
                "last_modified": {
                  "type""string"
                },
                "customfields": {
                  "type""string"
                },
                "attached_files": {
                  "type""array"
                },
                "created_by_user_id": {
                  "type""integer"
                }
              }
            }
          }
        }
      }
    }
  }
}
 
PA2.PNGPA3.PNGPA11.PNG
1 ACCEPTED SOLUTION

Accepted Solutions

 

Hi @thomas1992UK ,

 

Unfortunately, I am not able to provide a suitable method to extract the data from this response temporarily.

Because the object name is not fixed, so we could not get the property value by using the object name.

Do you have any other methods to get the id?

73.PNG

 

Best Regards,

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

View solution in original post

4 REPLIES 4
efialttes
Super User
Super User

I have bad news, I am afraid. We discussed a similar topic some weeks ago, but found no way to fix it so far but to redesign the source data model
https://powerusers.microsoft.com/t5/Building-Flows/Parse-JSON-Dynamic-number-as-object-s-name/td-p/5...
Let's hope this time somebody else can point us in the right direction


Each time you click on any of our inspiring answers 'Thumb up' icon...
...an ewok scapes from the stormtroopers.

Be grateful, Thumbs up! Save the Galaxy for free!


Escribo sobre Power Automate en:
https://medium.com/anyone-can-automate/

Proud to be a Flownaut!



v-bacao-msft
Community Support
Community Support

 

Hi @thomas1992UK ,

 

It seems that it is difficult to extract the data you need through Parse JSON.

 

First of all, timesheets is not an array, it is an object, so we cannot traverse it by Apply to each,

 

Second, the name of the object contained in timesheets is not fixed, which also prevents us from obtaining the object value through the object name.

 

If you can get the id first by other methods, maybe we can also extract the data by id, but it seems that your current need is to get the id.

 

Best Regards,

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

Hi Barry,

 

Could you help me with the following:

 

Split the output in to sections - e.g get the output like the below.

                 "id"153482,
                "user_id"76985,
                "jobcode_id"863233,
                "start""",
                "end""",
                "duration"18000,
                "date""2020-04-07",
                "tz"12,
                "tz_str""Pacific/Auckland",
                "type""manual",
                "location""TSheets web",
                "on_the_clock"false,
                "locked"0,
                "notes""",
                "last_modified""2020-04-13T23:45:50+00:00",
                "customfields""",
                "attached_files": [],
                "created_by_user_id"74317
 
Get the "id" and "duration" for each section?
 

 

Hi @thomas1992UK ,

 

Unfortunately, I am not able to provide a suitable method to extract the data from this response temporarily.

Because the object name is not fixed, so we could not get the property value by using the object name.

Do you have any other methods to get the id?

73.PNG

 

Best Regards,

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

View solution in original post

Helpful resources

Announcements
UG GA Amplification 768x460.png

Launching new user group features

Learn how to create your own user groups today!

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

M365 768x460.jpg

Microsoft 365 Collaboration Conference | December 7–9, 2021

Join us, in-person, December 7–9 in Las Vegas, for the largest gathering of the Microsoft community in the world.

Top Solution Authors
Users online (3,575)