JSON Key Lookup

Hi there,

Curious if anyone has any good suggestions on the below problem. We are trying to get the keys from a JSON array object. The keys unfortunately are dates and are dynamic. For example, the below works fine, but it's hard-coding "09/03/2017". Any way to get all the keys from the object properly? Worth noting that index(local!list, 1) does not work in the below case.
=with(
local!json: "{
""09/03/2017"": {
""total"": 5
},
""10/03/2017"": {
""total"": 5
}
}",
local!list: a!fromJson(local!json),
index(local!list, "09/03/2017")
)

OriginalPostID-268859

  Discussion posts and replies are publicly visible

Parents
  • Hi, Please find the below code, little lengthy but might help to your requirement:

    with(
    local!json: "{
    ""09/03/2017"": {
    ""total"": 5
    },
    ""10/03/2017"": {
    ""total"": 10
    }
    }",
    /*Convert into Appian value*/
    local!data: a!fromJson(
    local!json
    ),
    /*Split to fetch key type date values*/
    local!divideTheData: split(
    split(
    local!data,
    ":"
    ),
    ","
    ),
    /*To remove unwanted characters*/
    local!updatedData: a!forEach(
    local!divideTheData,
    stripwith(
    fv!item,
    "["
    )
    ),
    local!fetchDesiredData: a!forEach(
    local!updatedData,
    if(
    find(
    "/",
    fv!item
    ),
    true(),
    null
    )
    ),
    index(
    local!updatedData,
    where(
    local!fetchDesiredData
    )
    )
    )
Reply
  • Hi, Please find the below code, little lengthy but might help to your requirement:

    with(
    local!json: "{
    ""09/03/2017"": {
    ""total"": 5
    },
    ""10/03/2017"": {
    ""total"": 10
    }
    }",
    /*Convert into Appian value*/
    local!data: a!fromJson(
    local!json
    ),
    /*Split to fetch key type date values*/
    local!divideTheData: split(
    split(
    local!data,
    ":"
    ),
    ","
    ),
    /*To remove unwanted characters*/
    local!updatedData: a!forEach(
    local!divideTheData,
    stripwith(
    fv!item,
    "["
    )
    ),
    local!fetchDesiredData: a!forEach(
    local!updatedData,
    if(
    find(
    "/",
    fv!item
    ),
    true(),
    null
    )
    ),
    index(
    local!updatedData,
    where(
    local!fetchDesiredData
    )
    )
    )
Children
No Data