web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Constructing JSON with...
Power Apps
Unanswered

Constructing JSON with sub Table

(0) ShareShare
ReportReport
Posted on by 119

I'm constructing JSON to pass to the Bing Maps API.  I'm using a flow to do the heavy lifting, but I'm struggling with getting the JSON properly formatted.  The issue is with a subtable field inside of the main record.  You can add a "[" to the collection and it will properly format when you use JSON formula in PA.  However, instead of just adding the subtable it adds "Value: {" before the subtable which is improperly formatted JSON.

 

Here is a snippet of code that I'm looking to create (properly formatted).  The item of concern is after "shifts"

 

 

{
 "agents": [
 {
 "name": "agentName",
 "shifts": [
 {
 "startTime": "2019-11-09T08:00:00",
 "startLocation": {
 "latitude": 47.694117204371,
 "longitude": -122.378188970181
 },
 "endTime": "2019-11-09T18:00:00",
 "endLocation": {
 "latitude": 47.7070790545669,
 "longitude": -122.355226696231
 },
 "breaks": [{
 "startTime": "2019-11-09T12:00:00",
 "endTime": "2019-11-09T14:00:00",
 "duration": "00:30:00"
 },
 {
 "startTime": "2019-11-09T16:00:00",
 "endTime":"2019-11-09T16:30:00" 
 }
 ]
 }
 ],

 

 

 Here is what happens if I replicate the structure in PowerApps.

 

 

{
 "agents": [
 {
 "name": "DOE,JANE",
 "shifts": [
 {
 "Value": {
 "address": "8000 65TH AVENUE NORTH, BROOKLYN PARK, MN 55428",
 "endTime": "2022-08-09T17:00:00",
 "startTime": "2022-08-09T08:00:00"
 }
 }
 ]
 },

 

 

Here is the snippet of code where I'm collecting the data that creates the above JSON:

 

 

ForAll(Distinct(CollTest,Resource),
 Collect(CollAgentsData,
 {name:Result,
 shifts: [
 {startTime:"2022-08-09T08:00:00",
 address:LookUp(CollAgentAddresses,ResourceName=Result).Address, 
 endTime:"2022-08-09T17:00:00"
 }
 ]
 }
 )
);

 

 

How do I get rid of that extra Value: { section after shifts: ?

Categories:
I have the same question (0)
  • MarvinBangert Profile Picture
    1,924 Most Valuable Professional on at

    Hey @Tommy-Upton 

    could you please try to replace the

    shifts: [
     {...},
     {...}
    ]

    with

    shifts: Table(
     {...},
     {...}
    )

    This should create one table not two tables within itself and should eliminate the "value:".

     

    Here is an example:

    MarvinBangert_0-1660167675550.png

    Result:

    MarvinBangert_1-1660167845913.png

     

    Does this help you? Otherwise please give me some more information.

    Best regards
    Marvin

    If you like this post, give a Thumbs up. If it solved your request, Mark it as a Solution to enable other users to find it.

    Blog: Cloudkumpel

     

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Users!

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Congratulations to the March Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
11manish Profile Picture

11manish 551

#2
WarrenBelz Profile Picture

WarrenBelz 430 Most Valuable Professional

#3
Valantis Profile Picture

Valantis 298

Last 30 days Overall leaderboard