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

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Create a table from a ...
Power Apps
Unanswered

Create a table from a JSON object

(0) ShareShare
ReportReport
Posted on by 12

Hello,

 

I'm trying to create a table with column names specified in a variable.

I read that I can create a JSON object and use the variable as one of the property names, which I completed like so:

Set (jsnString, "{""items"":{""properties"":{" &
Concat(colTest,""" & Text(Value) & """: {""type"": ""string""},") &
"},""required"": [],""type"":""object""},""type"":""array""}");

Set(jsnString2, Substitute(jsnString,"},}","}}"));
Where colTest contains a table with 1 column and each record contains the column names I want.
The resulting string is:
"{\"items\":{\"properties\":{\"Column 1\":{\"type\":\"string\"},{\"Column 2\": {\"type\": \"string\"},{\"Column 3\": {\"type\": \"string\"},{\"Column 4\": {\"type\": \"string\"}},\"required\": [],\"type\":\"object\"},\"type\":\"array\"}"
The problem comes when Parse this and try to wrap it in a Table:
Set(myJSONObject, ParseJSON(jsnString2));
ClearCollect(coljson,Table(myJSONObject));
It throws an error and wants a Table whereas I am passing an object. 
Any ideas on how to convert this object to a table?
 
Thank you!
Categories:
I have the same question (0)
  • Verified answer
    v-bofeng-msft Profile Picture
    on at

    Hi @Dewie68 ,

     

    I assume there is a JSON string:

    Set(jsnString,"[{""Column1"":""1"",""Column2"":""1"",""Column3"":""1"",""Column4"":""1""}]");

    The code should be:

    Set(jsnString,"[{""Column1"":""1"",""Column2"":""1"",""Column3"":""1"",""Column4"":""1""}]");
    Set(myJSONObject, ParseJSON(jsnString));
    ClearCollect(
     coljson,
     ForAll(
     Table(myJSONObject),
     {
     Column1:Text(ThisRecord.Value.Column1),
     Column2:Text(ThisRecord.Value.Column2),
     Column3:Text(ThisRecord.Value.Column3),
     Column4:Text(ThisRecord.Value.Column4) 
     }));

    Best Regards,
    Bof

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

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 717 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 329 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 268

Last 30 days Overall leaderboard