How to call properties/methods of a javascript object from server side object
<p>I normally get a js object from restful resource Web Api 2 using C#, jQuery 2.x, Chrome as a browser like this</p>

<p><strong>C#</strong></p>

<pre><code>public class Employee
{
   private int id;
   private string firstName;
   private string lastName;

   public int ID
   {
      get{ return this.id; }
      set{ this.id = value; }
   }

   public string FirstName
   {
      get{ return this.firstName; }
      set{ this.firstName = value; }
   }

   public string LastName
   {
      get{ return this.lastName; }
      set{ this.lastName = value; }
   }

   public string FullName
   {
      get{ return this.firstName + " " + this.lastName; }
   }   
}
</code></pre>

<p>I have a controller like this</p>

<pre><code>public class EmployeeController : ApiController
{

   [HttpGet]
   public Employee GetEmployee(int id)
   {
      return EmployeeService.Instance.GetEmployee(id);
   }

}
</code></pre>

<p>Then in my js I call the resource like this</p>

<pre><code>function getEmployee(id) {
    $.ajax({
        type: "GET",
        url: "localhost:8080/Employee/" + id,
        success: bindEmployee
    });
}

function bindEmployee(employee){
   alert(employee.FullName);
}
</code></pre>

<p><strong>Java</strong></p>

<p>Now I want to do same thing in Java using Jersey 2.23, Java json 1.0, Tomcat 8. So my class Employee</p>

<pre><code>public class Employee{
  private int ID;
  private string firstName;
  private string lastName;

  //regular getter and setter methods

  public string getFullName(){
     return this.firstName + " " + this.lastName;
  }
}
</code></pre>

<p>This is my restful resource</p>

<pre><code>@Path("/employee")
public class EmployeeController {

    @GET
    @Produces(MediaType.APPLICATION_JSON)
    public Response getEmployee(@PathParam("id") long id) throws JSONException{
        Employee employee = new Employee();
        employee.setId(id);
        employee.setFirstName("john");
        employee.setLastName("smith");
        return Response.status(200).entity(employee).build();
    }
}
</code></pre>

<p>I call the restful resource with $http object from angularjs like this</p>

<pre><code>return $http({
 method : 'GET',
 url : 'localhost:8080/employee/1',
}).then(onSuccess, onError);

function onSuccess(response){
   return response.data;
}

function onError(response){
//
}
</code></pre>

<p>The response data is my employee but I can only see the private members, but I cannot call the getFullName method. Is not in a JSON string, it is a Javascript object.</p>

<p>Is there a workaround to call the getFullName in javascript? I want to avoid a client side concatenation like this firstName + " "+ lastName.  </p>

<p>This is the output from developer tools in Chrome.</p>

<p><a href="https://i.stack.imgur.com/iydIh.png" rel="nofollow"><img src="https://i.stack.imgur.com/iydIh.png" alt="enter image description here"></a></p>