cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
dajmunozos
New Member

Failed convert string to JSON

Hi all, I try to create a block of options to append in a adaptive card, for this I create a loop to append to a string each option, after I use the function JSON() to convert and add to other activity to complete adaptive card code, but the output of JSON() function only create JSON format for 1 option:

 

Compose to remove the last character (',') with all string

dajmunozos_0-1646233145214.png

the complete output is: {"type":"Container", "items": [{"type": "ColumnSet","id":"TableGroupChoiceSelection0","columns": [{"type": "Column","width": "stretch","id": "ColGroupName0","items": [{"type": "Input.ChoiceSet","choices": [{"title": "Definicion Gobierno Automatizacion","value": "Definicion Gobierno Automatizacion"}],"placeholder": "Seleccione de las siguientes opciones","id": "nameTeamChoices0","style": "expanded","isMultiSelect": true,"spacing": "None","separator": true}],"horizontalAlignment": "Left","verticalContentAlignment": "Center","height": "stretch"},{"type": "Column","width": "stretch","id": "ColTypeGroup0","items": [{"type": "Input.ChoiceSet","choices": [{"title": "1.Proyecto","value": "1.Proyecto"},{"title": "2.Operación","value": "2.Operación"},{"title": "3.Proveedores","value": "3.Proveedores"},{"title": "4.Grupo","value": "4.Grupo"},{"title": "5.Eventos","value": "5.Eventos"},{"title": "6.Comunicación","value": "6.Comunicación"},{"title": "7.Ninguno de los anteriores","value": "7.Ninguno de los anteriores"}],"placeholder": "Tipo de grupo","id": "typeTeamChoices0"}],"height": "stretch"}]}],"id": "TableRow0"},{"type":"Container", "items": [{"type": "ColumnSet","id":"TableGroupChoiceSelection1","columns": [{"type": "Column","width": "stretch","id": "ColGroupName1","items": [{"type": "Input.ChoiceSet","choices": [{"title": "Elaborar propuesta de Gobierno Automatizacion","value": "Elaborar propuesta de Gobierno Automatizacion"}],"placeholder": "Seleccione de las siguientes opciones","id": "nameTeamChoices1","style": "expanded","isMultiSelect": true,"spacing": "None","separator": true}],"horizontalAlignment": "Left","verticalContentAlignment": "Center","height": "stretch"},{"type": "Column","width": "stretch","id": "ColTypeGroup1","items": [{"type": "Input.ChoiceSet","choices": [{"title": "1.Proyecto","value": "1.Proyecto"},{"title": "2.Operación","value": "2.Operación"},{"title": "3.Proveedores","value": "3.Proveedores"},{"title": "4.Grupo","value": "4.Grupo"},{"title": "5.Eventos","value": "5.Eventos"},{"title": "6.Comunicación","value": "6.Comunicación"},{"title": "7.Ninguno de los anteriores","value": "7.Ninguno de los anteriores"}],"placeholder": "Tipo de grupo","id": "typeTeamChoices1"}],"height": "stretch"}]}],"id": "TableRow1"},{"type":"Container", "items": [{"type": "ColumnSet","id":"TableGroupChoiceSelection2","columns": [{"type": "Column","width": "stretch","id": "ColGroupName2","items": [{"type": "Input.ChoiceSet","choices": [{"title": "Gestion de pendientes","value": "Gestion de pendientes"}],"placeholder": "Seleccione de las siguientes opciones","id": "nameTeamChoices2","style": "expanded","isMultiSelect": true,"spacing": "None","separator": true}],"horizontalAlignment": "Left","verticalContentAlignment": "Center","height": "stretch"},{"type": "Column","width": "stretch","id": "ColTypeGroup2","items": [{"type": "Input.ChoiceSet","choices": [{"title": "1.Proyecto","value": "1.Proyecto"},{"title": "2.Operación","value": "2.Operación"},{"title": "3.Proveedores","value": "3.Proveedores"},{"title": "4.Grupo","value": "4.Grupo"},{"title": "5.Eventos","value": "5.Eventos"},{"title": "6.Comunicación","value": "6.Comunicación"},{"title": "7.Ninguno de los anteriores","value": "7.Ninguno de los anteriores"}],"placeholder": "Tipo de grupo","id": "typeTeamChoices2"}],"height": "stretch"}]}],"id": "TableRow2"},{"type":"Container", "items": [{"type": "ColumnSet","id":"TableGroupChoiceSelection3","columns": [{"type": "Column","width": "stretch","id": "ColGroupName3","items": [{"type": "Input.ChoiceSet","choices": [{"title": "Proyectos Procesos BPM Bizagi","value": "Proyectos Procesos BPM Bizagi"}],"placeholder": "Seleccione de las siguientes opciones","id": "nameTeamChoices3","style": "expanded","isMultiSelect": true,"spacing": "None","separator": true}],"horizontalAlignment": "Left","verticalContentAlignment": "Center","height": "stretch"},{"type": "Column","width": "stretch","id": "ColTypeGroup3","items": [{"type": "Input.ChoiceSet","choices": [{"title": "1.Proyecto","value": "1.Proyecto"},{"title": "2.Operación","value": "2.Operación"},{"title": "3.Proveedores","value": "3.Proveedores"},{"title": "4.Grupo","value": "4.Grupo"},{"title": "5.Eventos","value": "5.Eventos"},{"title": "6.Comunicación","value": "6.Comunicación"},{"title": "7.Ninguno de los anteriores","value": "7.Ninguno de los anteriores"}],"placeholder": "Tipo de grupo","id": "typeTeamChoices3"}],"height": "stretch"}]}],"id": "TableRow3"},{"type":"Container", "items": [{"type": "ColumnSet","id":"TableGroupChoiceSelection4","columns": [{"type": "Column","width": "stretch","id": "ColGroupName4","items": [{"type": "Input.ChoiceSet","choices": [{"title": "Robotic Process Automation (RPA)","value": "Robotic Process Automation (RPA)"}],"placeholder": "Seleccione de las siguientes opciones","id": "nameTeamChoices4","style": "expanded","isMultiSelect": true,"spacing": "None","separator": true}],"horizontalAlignment": "Left","verticalContentAlignment": "Center","height": "stretch"},{"type": "Column","width": "stretch","id": "ColTypeGroup4","items": [{"type": "Input.ChoiceSet","choices": [{"title": "1.Proyecto","value": "1.Proyecto"},{"title": "2.Operación","value": "2.Operación"},{"title": "3.Proveedores","value": "3.Proveedores"},{"title": "4.Grupo","value": "4.Grupo"},{"title": "5.Eventos","value": "5.Eventos"},{"title": "6.Comunicación","value": "6.Comunicación"},{"title": "7.Ninguno de los anteriores","value": "7.Ninguno de los anteriores"}],"placeholder": "Tipo de grupo","id": "typeTeamChoices4"}],"height": "stretch"}]}],"id": "TableRow4"}

 

After, I use the function JSON(outputs('EliminarUltimoCaracter')) to convert all string to JSON, but the output is this:

dajmunozos_1-1646233279341.png

{
  "type""Container",
  "items": [
    {
      "type""ColumnSet",
      "id""TableGroupChoiceSelection0",
      "columns": [
        {
          "type""Column",
          "width""stretch",
          "id""ColGroupName0",
          "items": [
            {
              "type""Input.ChoiceSet",
              "choices": [
                {
                  "title""Definicion Gobierno Automatizacion",
                  "value""Definicion Gobierno Automatizacion"
                }
              ],
              "placeholder""Seleccione de las siguientes opciones",
              "id""nameTeamChoices0",
              "style""expanded",
              "isMultiSelect"true,
              "spacing""None",
              "separator"true
            }
          ],
          "horizontalAlignment""Left",
          "verticalContentAlignment""Center",
          "height""stretch"
        },
        {
          "type""Column",
          "width""stretch",
          "id""ColTypeGroup0",
          "items": [
            {
              "type""Input.ChoiceSet",
              "choices": [
                {
                  "title""1.Proyecto",
                  "value""1.Proyecto"
                },
                {
                  "title""2.Operación",
                  "value""2.Operación"
                },
                {
                  "title""3.Proveedores",
                  "value""3.Proveedores"
                },
                {
                  "title""4.Grupo",
                  "value""4.Grupo"
                },
                {
                  "title""5.Eventos",
                  "value""5.Eventos"
                },
                {
                  "title""6.Comunicación",
                  "value""6.Comunicación"
                },
                {
                  "title""7.Ninguno de los anteriores",
                  "value""7.Ninguno de los anteriores"
                }
              ],
              "placeholder""Tipo de grupo",
              "id""typeTeamChoices0"
            }
          ],
          "height""stretch"
        }
      ]
    }
  ],
  "id""TableRow0"
}

 

Anybody knows how to convert and get the complete string in format JSON.

1 ACCEPTED SOLUTION

Accepted Solutions
CFernandes
Super User
Super User

Hey Mate @dajmunozos 

 

I copy your JSON and paste it in a JSON Validator it complains that the JSON is not valid - https://jsonlint.com/ 

 

Can you first check if your JSON is valid - Once confirmed please check the article(https://jd-bots.com/2021/10/17/convert-string-to-json-using-power-automate-microsoft-flow-work-with-...) I assume you are using the same concept but its good to check.

 

If this reply has answered your question or solved your issue, please mark this question as answered. Answered questions helps users in the future who may have the same issue or question quickly find a resolution via search. If you liked my response, please consider giving it a thumbs up. THANKS!

 

P.S. take a look at my blog here and like & subscribe to my YouTube Channel thanks.

 

View solution in original post

2 REPLIES 2
CFernandes
Super User
Super User

Hey Mate @dajmunozos 

 

I copy your JSON and paste it in a JSON Validator it complains that the JSON is not valid - https://jsonlint.com/ 

 

Can you first check if your JSON is valid - Once confirmed please check the article(https://jd-bots.com/2021/10/17/convert-string-to-json-using-power-automate-microsoft-flow-work-with-...) I assume you are using the same concept but its good to check.

 

If this reply has answered your question or solved your issue, please mark this question as answered. Answered questions helps users in the future who may have the same issue or question quickly find a resolution via search. If you liked my response, please consider giving it a thumbs up. THANKS!

 

P.S. take a look at my blog here and like & subscribe to my YouTube Channel thanks.

 

Thanks!, I check this extract for the JSON and is true, the JSON is not valid so to fix that I create two string variables and after create a options for the adaptive card I add this part to the main JSON and when use the compose to convert to JSON the result is successful.

Helpful resources

Announcements
Microsoft 365 Conference – December 6-8, 2022

Microsoft 365 Conference – December 6-8, 2022

Join us in Las Vegas to experience community, incredible learning opportunities, and connections that will help grow skills, know-how, and more.

Users online (1,693)