I want to show the results of a Json response on a Visualforce page. At this moment im able to deserialize and show the results, but when I try to show the result of the Class in the visual force it shows the following error:

enter image description here

For testing i want to show in the VF page "Razon Social" of the class Empresa.

This is the class:

public class EquifaxEmpresa {

public List<Empresa> Empresa;

public class Empresa{
    public String RazonSocial; 
    public String NombreComercial;  
    public String TipoContribuyente; 
    public String EstadoContribuyente;
    public String CondicionContribuyente; 
    public String Dependencia; 
    public String CodigoCIIU; 
    public String DescripcionCIIU; 
    public String InicioActividades; 
    public String ActividadComercioExterior; 
    public String NumeroTrabajadores; 
    public String Direccion;
public static EquifaxEmpresa parse(String json){
    return (EquifaxEmpresa) System.JSON.deserialize(json, EquifaxEmpresa.class);

This is the controller class:

global class equifaxController {
public String idConsulta {get;set;}
public EquifaxEmpresa theEmpresa {get;set;}
public String mensaje {get;set;}

public void consultaPersona(){

    string msj = '{'+

    Http http = new Http();
    HttpRequest req = new HttpRequest();
    req.setEndpoint('endpoint here');

    HttpResponse res = new HttpResponse();

    //EquifaxEmpresa empresita = (EquifaxEmpresa)JSON.deserialize(msj, EquifaxEmpresa.class);

    res = Http.send(req);
    String temp = res.toString();

        system.debug('Error: '+res.getStatusCode());
        String body = res.getBody();
        theEmpresa = EquifaxEmpresa.parse(body);
        mensaje = body;

The visualforce page:

<apex:page controller="equifaxController">

       <apex:pageBlock title="Datos de Empresa">
           <apex:form >
            <apex:inputText value="{!idConsulta }"/>
            <apex:commandButton value="Consultar" action="{!consultaPersona}" reRender="dynamic"/>

    <apex:outputPanel id="dynamic">


The other thing that I cannot understand, its why system.debug shows me {!theEmpresa.Empresa[0].RazonSocial} and VF not:

enter image description here

Thanks in advance

  • 1
    I think declaring it like this public List<Empresa> Empresa {get;set} should solve the issue. Jan 3, 2020 at 16:31

1 Answer 1


Visualforce requires a "getter" and "setter" to reference a variable in the controller or extension. Without a getter or setter, even public or global variables cannot be referenced in Visualforce expressions.

So declare the list like this:

public List<Empresa> Empresa {get;set}
public String RazonSocial {get;set}
  • In the problems section appears: Invalid Type: Empresa Jan 3, 2020 at 16:48
  • 1
    Refer the updated answer. Jan 3, 2020 at 16:50
  • these declarations go in the Controller or the empresa class? Thanks for your help. Jan 3, 2020 at 16:53
  • 2
    Yes, you've already declared it, just append it with getter and setters Jan 3, 2020 at 16:54
  • 1
    Thanks!! It worked. Jan 3, 2020 at 17:01

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .