{
"SAP": [
{% for Record in content %}{
{% assign res = Record.d['results'] %}
"SSO ID": "{{ res[0].username }}"
},
{% endfor %}
]
}
Using this - i am only able to get username field of the first element from both results but not the second element. I want to be able to iterate through all the elements both results and get their values..
PLEASE HELP!!
For our requirement, I initialize a variable named "data" and store the below value to simulate your situation.
{
"content": [
{
"d": {
"results": [
{
"username": "hury11",
"email": "test@mail.com"
},
{
"username": "hury22",
"email": "test@mail.com"
},
{
"username": "hury33",
"email": "test@mail.com"
}
],
"_count": "17425",
"_next": ""
}
},
{
"d": {
"results": [
{
"username": "hury44",
"email": "test@mail.com"
},
{
"username": "hury55",
"email": "test@mail.com"
},
{
"username": "hury66",
"email": "test@mail.com"
}
],
"_count": "17425",
"_next": ""
}
}
]
}
Then parse json and use "Transform JSON to JSON" action.
My liquid template shown as below:
{
"SAP": [
{% for Record in content %}
[
{% for result in Record.d.results %}
{
"SSO ID": "{{result.username}}",
"email": "{{result.email}}"
},
{% endfor %}
],
{% endfor %}
]
}
If you want the d
map in your result json data, the liquid template should be as below:
{
"SAP": [
{% for Record in content %}
{"d":
[
{% for result in Record.d.results %}
{
"SSO ID": "{{result.username}}",
"email": "{{result.email}}"
},
{% endfor %}
]
},
{% endfor %}
]
}
Hope it helps~