Handling a API response JSON

I’m trying to read a JSON like this:

{

"id": "56841",

"canUpdate": true,

"canDelete": true,

"canArchive": true,

"hasChildren": false,

"info": [

    {

        "key": "third_level_category",

        "value": "Importação",

        "valueClass": "",

        "mandatory": false,

        "editable": true,

        "type": "list",

        "defaultValue": null,

        "keyCaption": "Categoria de terceiro nível",

        "valueCaption": "Importação"

    },

    {

        "key": "problem_sub_type",

        "value": "Tecaplus",

        "valueClass": "",

        "mandatory": false,

        "editable": true,

        "type": "list",

        "defaultValue": null,

        "keyCaption": "Subcategoria",

        "valueCaption": "Tecaplus"

    },

    {

        "key": "CustomColumn171sr",

        "value": null,

        "valueClass": "",

        "mandatory": false,

        "editable": true,

        "type": "text",

        "defaultValue": null,

        "keyCaption": "Sugestão Nome de rede:",

        "valueCaption": ""

    },

    {

        "key": "CustomColumn191sr",

        "value": null,

        "valueClass": "",

        "mandatory": false,

        "editable": true,

        "type": "text",

        "defaultValue": null,

        "keyCaption": "Sugestão Nome de rede 3:",

        "valueCaption": ""

    },

    {

        "key": "CustomColumn190sr",

        "value": null,

        "valueClass": "",

        "mandatory": false,

        "editable": true,

        "type": "text",

        "defaultValue": null,

        "keyCaption": "Sugestão Nome de rede 2:",

        "valueCaption": ""

    },

    {

        "key": "CustomColumn210sr",

        "value": null,

        "valueClass": "",

        "mandatory": false,

        "editable": true,

        "type": "list",

        "defaultValue": null,

        "keyCaption": "Usuário Terceiro",

        "valueCaption": ""

    },

    {

        "key": "description",

        "value": "Solicito a criação de um relatório \" espécie\" extrato de apoio onde as informações capturadas do Mantra sejam cruzadas com as do tecaplus  após a migração de dados.",

        "valueClass": "",

        "mandatory": false,

        "editable": true,

        "type": "text",

        "defaultValue": null,

        "keyCaption": "Descrição",

        "valueCaption": "Solicito a criação de um relatório \" espécie\" extrato de apoio onde as informações capturadas do Mantra sejam cruzadas com as do tecaplus  após a migração de dados."

    },

    {

        "key": "problem_type",

        "value": "Sistemas",

        "valueClass": "",

        "mandatory": false,

        "editable": true,

        "type": "nested",

        "defaultValue": null,

        "keyCaption": "Categoria",

        "valueCaption": "Sistemas"

    },

    {

        "key": "title",

        "value": "Criação de Relatório - Recebimento Prévio.",

        "valueClass": "",

        "mandatory": false,

        "editable": true,

        "type": "text",

        "defaultValue": null,

        "keyCaption": "Título",

        "valueCaption": "Criação de Relatório - Recebimento Prévio."

    },

    {

        "key": "status",

        "value": 15,

        "valueClass": 1,

        "mandatory": false,

        "editable": true,

        "type": "list",

        "defaultValue": null,

        "keyCaption": "Status",

        "valueCaption": "Encerrado"

    }

]

}

With this code (inside a AE Loop, with index var for the iterations):
var obj = ChamaRespBody;
var chamadoJAVA = obj.id;
var loginJAVA, login2JAVA, login3JAVA, descricaoJAVA = “”;
var problem_typeJAVA, problem_sub_typeJAVA, third_level_categoryJAVA, user_terceiroJAVA, tituloJAVA, statusJAVA, finalizaJAVA = false;

var valida = typeof obj.info[index];

if (valida !== “undefined”) {

var key = obj.info[index].key;
var value = obj.info[index].value;

if (key === "problem_type" && value === "INFRA-FIELD") {
    problem_typeJAVA = true;
}
if (key === "problem_sub_type" && value === "Movimentação de Pessoa") {
    problem_sub_typeJAVA = true;
}
if (key === "third_level_category" && value === "Provisionamento") {
    third_level_categoryJAVA = true;
}
if (key === "status" && value === "1") {
    statusJAVA = true;
}
if (key === "CustomColumn210sr" && value !== null) {
    user_terceiroJAVA = true;
}
if (key === "title" && value === "Padrão Solicitação - Novo Integrante Modelo") {
    tituloJAVA = true;
}
if (key === "CustomColumn171sr") {
    loginJAVA = value;
}
if (key === "CustomColumn190sr") {
    login2JAVA = value;
}
if (key === "CustomColumn191sr") {
    login3JAVA = value;
}
if (key === "description") {
    descricaoJAVA = value;
}

if (problem_typeJAVA && problem_sub_typeJAVA && third_level_categoryJAVA && statusJAVA && user_terceiroJAVA && tituloJAVA) {
    finalizaJAVA = true;
}

}

It works in any JavaScript Compiler, but i keep receiving a error like this:
Javascript error: TypeError: Cannot read property “0” from undefined (script#6)

But, if i set an Alert in line 6(Alert(obj.info[index].value)) it returns the exact value in every iteration.

What can I be doing wrong?

Hello Wesley.selmer

The problem according to me was you were not reading the JSON properly. I tried your use case with a different approach. I’ve attached the workflow for the same.
WF_ModifiedJavaScript.psw (25.9 KB)