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 / JSON Array Convert Error
Power Apps
Answered

JSON Array Convert Error

(0) ShareShare
ReportReport
Posted on by Microsoft Employee

Hello!

In the power apps formula I want to use the JSON function to convert JSON into a string, but the following error occurred.

 

Error

lusoftware_0-1605754915416.png

 

Formula

 

 

JSON([
 {
 colorType: 6,
 display: "Source Type",
 id: "SourceType",
 operator: { display: "=", id: "COptionalEqual", valueType: 3 },
 value: { id: [1], display: ["Pubmed"] }
 },
 { display: "and", value: [{ display: "and" }] },
 {
 colorType: 1,
 display: "All Fields",
 id: "AllFields",
 operator: { display: "Contain", id: "AllFieldsContain", valueType: 1 },
 value: { display: "cancer" }
 }
 ])

 

 

 

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

    The JSON() function is for output data structures like collections and tables as as JSON string representation.  Its not really designed to work with ad-hoc data structures like the one you are embedding.

  • Verified answer
    v-bofeng-msft Profile Picture
    Microsoft Employee on at

    Hi @Anonymous :

    Firstly,let me explain why you encounted this problem:

    The key is that the data type of value is inconsistent.

    value: {id: [1], display: ["Pubmed"]}

    This means that the type of 'value' is object

    value: [{ display: "and" }]

    This means that the type of 'value' is array

    Secondly,you can try:

    JSON([
     {
     colorType: 6,
     display: "Source Type",
     id: "SourceType",
     operator: { display: "=", id: "COptionalEqual", valueType: 3 },
     value: { id: [1], display: ["Pubmed"] }
     },
     { display: "and", value: {display: ["and"] } },
     {
     colorType: 1,
     display: "All Fields",
     id: "AllFields",
     operator: { display: "Contain", id: "AllFieldsContain", valueType: 1 },
     value: {display:[ "cancer"] }
     }
     ])

     In addition,Json is a Behavioral formula.I suggest you use a buttion, store its value in a variable, and then call the variable directly.For example:

    Add a button and set it's OnSelect property to

    Set(myvar,JSON([
     {
     colorType: 6,
     display: "Source Type",
     id: "SourceType",
     operator: { display: "=", id: "COptionalEqual", valueType: 3 },
     value: { id: [1], display: ["Pubmed"] }
     },
     { display: "and", value: {display: ["and"] } },
     {
     colorType: 1,
     display: "All Fields",
     id: "AllFields",
     operator: { display: "Contain", id: "AllFieldsContain", valueType: 1 },
     value: {display:[ "cancer"] }
     }
     ]))

    Best Regards,

    Bof

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    Thanks, I know this is a bad way to use.

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 405 Super User 2026 Season 2

#2
Mohsin Ali Profile Picture

Mohsin Ali 368

#3
WarrenBelz Profile Picture

WarrenBelz 244 Most Valuable Professional

Last 30 days Overall leaderboard