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 / Why does JSON function...
Power Apps
Unanswered

Why does JSON function not support arrays?

(0) ShareShare
ReportReport
Posted on by 173

The JSON function does not seem to work at all with arrays:

 

Set(arrtest, JSON({arr: [1,2]}))

 

This should produce perfectly legal JSON however it insists on wanting to create key/value pairs, so instead it produces:

 

{"arr": [{"Value":1},{"Value":2}]}

 

Which is entirely incorrect. How can I get it to produce proper json for array data?

Categories:
  • Pstork1 Profile Picture
    69,665 Most Valuable Professional on at

    {arr: [1,2]} is a record of an object that contains a property that is an array.  That's exactly what the JSON() is translating it too.  For the JSON to work correctly the array has to be an array of Key/Value pairs.  Otherwise you will get the default key of "Value".  This is not an incorrect translation.  It is the proper translation of what you have submitted as JSON.

     

    {arr: [1,2]} is not the same thing as [{arr:1}, {arr:2}].  Which would convert to what you want as JSON.

  • camer314 Profile Picture
    173 on at

    I still cant get this to format JSON the way I want. I am trying to call a custom connector that accepts a json object, that object is defined as:

     

     public class ProductInput
     {
     public Collection<int> Values { get; set; }
     }

     

    If I create an instance of this in code and then serialize it I get what I expect, which is not something I can reproduce with the JSON formula:

     

    var x = new ProductInput()
    {
     Values = new System.Collections.ObjectModel.Collection<int>()
    };
    
    x.Values.Add(1);
    x.Values.Add(2);
    
    var s = JsonConvert.SerializeObject(x);
    
    // "{\"Values\":[1,2]}"

     

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

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Leaderboard > Power Apps

#1
11manish Profile Picture

11manish 360 Super User 2026 Season 2

#2
M Bilal Khan Profile Picture

M Bilal Khan 325

#3
Mohsin Ali Profile Picture

Mohsin Ali 232

Last 30 days Overall leaderboard