Pegar valor do Json e colocar na label do campo

Good night dear,

I’m having the following problem:

I’m using an integration connector with Rest API, to use Belvo’s API.

According to the text below, the API lists the records as follows:

{
“count”: 20,
“next”: null,
“previous”: null,
“results”: [
{
“id”: 420,
“name”: “bancodobrasil_br_business”,
“type”: “bank”,
“code”: null,
“website”: null,
“display_name”: “Banco do Brasil Empresa”,
“country_code”: “BR”,
“country_codes”: [
“BR”
],
“primary_color”: “#23569c”,
“logo”: null,
“icon_logo”: null,
“text_logo”: null,
“form_fields”: [
{
“name”: “username”,
“type”: “text”,
“label”: “Chave J”,
“validation”: “^J[A-Z0-9]{1}\d{6}$”,
“placeholder”: “Ex. JE123456”,
“validation_message”: “Formato incorreto (Ex. JE123456)”
},
{
“name”: “password”,
“type”: “password”,
“label”: “Senha chave J”,
“validation”: “^(?=.[A-z])(?=.[\d])([a-zA-Z\d]){8}$”,
“placeholder”: “Ex. 12345abc”,
“validation_message”: “Formato incorreto (Ex. 12345abc)”
},
{
“name”: “password2”,
“type”: “password”,
“label”: “Senha de 8 dígitos”,
“validation”: “^\d{8}$”,
“validation_message”: “Requer 8 dígitos”
},
{
“name”: “token”,
“type”: “string”,
“label”: “URL”,
“length”: “40”,
“optional”: true,
“validation”: “^(https:\/\/www49\.bb\.com\.br\/sms\/ato\?c=)+([0-9A-Z]){40}$”,
“validation_message”: “É necessário ser uma URL válida”
}
],
“customization”: null,
“features”: [
{
“name”: “token_required”,
“description”: “institution may need a token during link creation / login”
}
],
“integration_type”: “credentials”,
“status”: “healthy”,
“resources”: [
“ACCOUNTS”,
“BALANCES”,
“OWNERS”,
“TRANSACTIONS”
],
“openbanking_information”: null
},
{
“id”: 25,
“name”: “bancodobrasil_br_retail”,
“type”: “bank”,
“code”: null,
“website”: null,
“display_name”: “Banco do Brasil”,
“country_code”: “BR”,
“country_codes”: [
“BR”
],
“primary_color”: “#23569c”,
“logo”: null,
“icon_logo”: null,
“text_logo”: null,
“form_fields”: [
{
“name”: “username”,
“type”: “text”,
“label”: “Agência”,
“validation”: “^\d{4}-\d{1}$”,
“placeholder”: “Ex. 1122-5”,
“validation_message”: “Formato incorreto (Ex. 1122-5)”
},
{
“name”: “username2”,
“type”: “text”,
“label”: “Conta”,
“validation”: “^\d{1,11}-[A-Za-z0-9]{1}$”,
“placeholder”: “Ex. 11224-7”,
“validation_message”: “Formato incorreto (Ex. 11224-7 ou 12345678901-1)”
},
{
“name”: “password”,
“type”: “password”,
“label”: “Senha de 8 dígitos”,
“validation”: “^\d{8}$”,
“validation_message”: “Requer 8 dígitos”
}
],
“customization”: null,
“features”: ,
“integration_type”: “credentials”,
“status”: “healthy”,
“resources”: [
“ACCOUNTS”,
“TRANSACTIONS”,
“OWNERS”,
“RECURRING_EXPENSES”,
“RISK_INSIGHTS”,
“BALANCES”,
“INCOMES”,
“INVESTMENTS_PORTFOLIOS”
],
“openbanking_information”: null
},
{
“id”: 453,
“name”: “bancointer_br_business”,
“type”: “bank”,
“code”: null,
“website”: null,
“display_name”: “Banco Inter Empresa”,
“country_code”: “BR”,
“country_codes”: [
“BR”
],
“primary_color”: “#FF8700”,
“logo”: “https://statics.development.belvo.io/institutions/text_logos/inter_text.svg”,
“icon_logo”: “https://statics.development.belvo.io/institutions/icon_logos/inter_icon.svg”,
“text_logo”: “https://statics.development.belvo.io/institutions/text_logos/inter_text.svg”,
“form_fields”: [
{
“name”: “username”,
“type”: “text”,
“label”: “Operador”,

As you can see it generates a response from all the records and within these records it has a “form_fields” which would be the fields that the institution uses to validate the user in which each one has its particularity.

I need to know how to make the correct application of all form_fields and if I find one in which the name field has the word username, it will return the value of the label field in the Json.

Could you help with this issue?

First of all, I would like to explain for the newer ones what all those variables mean so that when a person sees our comment, they know what we are talking about.

It looks like the Belvo API is returning you information about different financial institutions and their login requirements. Each financial institution has an “id”, a “name” and a “type” (bank, credit card, etc.), as well as a series of form fields that must be completed to log in. Each form field has a “name”, a “type” (text, password, etc.), a “label” and a “validation” that specifies how the information provided should be formatted. There are also some other features and resources available for each financial institution.

I hope I’m not wrong, as I don’t have my PC handy due to my vacation and it becomes difficult to validate. However, you can have an example if it helps you and if you know some JSON (Python) so you have some idea while in the community they can help you.

import json

Assuming that you have the response from the Belvo API in a variable called response

response = json.loads(response)

We iterate over the records

for result in response[“results”]:

We iterate over the form fields of each record.

for field in result[“form_fields”]:
# If the field name is “username”
if field[“name”] == “username”:
# We return the value of the field label
print(field[“label”])

That you are very well.

Good evening,

Your answer is correct but I did not understand how this If would be performed that would bring the appropriate data in the composer of the platform panel