Values inside array inside get of REST

How I can get values inside array inside get of REST ?

The result of get is:

{“api_credentials”:{“status”:200,“headers”:{“server”:“nginx/1.14.0 (Ubuntu)”,“date”:“Mon, 21 Jun 2021 13:07:18 GMT”,“content-type”:“application/json; charset=utf-8”,“content-length”:“530”,“connection”:“close”},“data”:{“results”:[{“referent”:“bbde0036-c0f7-4632-91b2-fead2210a955”,“attrs”:{“cpf”:“123456789654123”},“schema_id”:“NDC1NBuWaTcNRn3MkxMUtm:2:dados:1.0”,“cred_def_id”:“NDC1NBuWaTcNRn3MkxMUtm:3:CL:18:default”,“rev_reg_id”:null,“cred_rev_id”:null},{“referent”:“eb11ecb7-1d08-446e-b83f-7a65e52a44e8”,“attrs”:{“cpf”:“1234567894656546”,“rg”:“123456789654123”},“schema_id”:“NDC1NBuWaTcNRn3MkxMUtm:2:identidade-serpro:1.0”,“cred_def_id”:“NDC1NBuWaTcNRn3MkxMUtm:3:CL:22:serpro”,“rev_reg_id”:null,“cred_rev_id”:null}]}}}

Position 1: {“referent”:“bbde0036-c0f7-4632-91b2-fead2210a955”,“attrs”:{“cpf”:“123456789654123”}

Position 2 : {“referent”:“eb11ecb7-1d08-446e-b83f-7a65e52a44e8”,“attrs”:{“cpf”:“1234567894656546”,“rg”:“123456789654123”}

How can I print the “attrs” dictionary with (Key/Value pairs) with the attribute and value on the user’s screen?

For example :

Postion 1:
cpf:123456789654123"

Position 2 :

cpf : 1234567894656546
rg : 123456789654123

Use a repeat region

Expression for the repeat will be something like:
apicomponentname.data.results

And then you can refer to ‘attrs’:
e.g.

<div class="row" is="dmx-repeat" id="repeat1" dmx-bind:repeat="api_conponentid.data.results">
        <div class="col">
            <p dmx-text="Position {{$index+1}}:"></p>
            <p dmx-text="attrs.cpf"></p>
            <p dmx-text="attrs.rg"></p>
        </div>
    </div>

Thanks

I can’t use ‘cpf’ and ‘rg’, because it’s can change. I need something like value and key, but it doesn’t work.

You can add another repeat for ‘attrs’ (inside the results repeat) within which you can refer to $key and $value

Its works, thanks.

1 Like