Showing results for 
Search instead for 
Did you mean: 
Helper I
Helper I

Why does JSON function not support arrays?

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?

Dual Super User III
Dual Super User III

{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.

If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.

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>()


var s = JsonConvert.SerializeObject(x);

// "{\"Values\":[1,2]}"


Helpful resources

PA User Group

Welcome to the User Group Public Preview

Check out new user group experience and if you are a leader please create your group

Power Query PA Forum 768x460.png

Check it out!

Did you know that you can visit the Power Query Forum in Power BI and now Power Apps

V3_PVA CAmpaign Carousel.png

Community Challenge - Giveaways!

Participate in the Power Virtual Agents Community Challenge

Carousel 2021 Release Wave 2 Plan 768x460.jpg

2021 Release Wave 2 Plan

Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.

Carousel April Dunnam Updated 768x460.jpg

Urdu Hindi D365 Bootcamp

Dont miss our very own April Dunnam’s The Developer Guide to the Galaxy! Find out what the Power Platform has to offer for the traditional developer.

Top Solution Authors
Top Kudoed Authors
Users online (2,371)