Converting Map to POJO with Jackson, Groovy complains for not having a property
<p>I’m trying to convert a Map from a http response to POJO. The response is</p>

<pre><code>{_total=0}
</code></pre>

<p>In my Pojo, I want to get rid of the underscore so I annotated the field with @JsonProperty. But Groovy complains for not having a _total property</p>

<p>Stacktrace</p>

<pre><code>org.codehaus.groovy.runtime.typehandling.GroovyCastException: Cannot cast object '{_total=0}' with class 'java.util.LinkedHashMap' to class 'io.toro.linkedin.response.CompanyAdminsResponse' due to: org.codehaus.groovy.runtime.metaclass.MissingPropertyExceptionNoStack: No such property: _total for class: io.toro.linkedin.response.CompanyAdminsResponse
Possible solutions: total

    at io.toro.linkedin.connector.LinkedInConnector.linkedInListCompaniesThatUserIsAdminOf(LinkedInConnector.groovy:314)
    at LinkedInTest.list-companies-that-user-is-admin-of(LinkedInTest.groovy:115)
</code></pre>

<p>Conversion code</p>

<pre><code>HttpResponseDecorator response = restClient.get(params)
ObjectMapper mapper = new ObjectMapper()
mapper.convertValue(response.data as Map, T)
</code></pre>

<p>POJO</p>

<pre><code>package io.toro.linkedin.response

import com.fasterxml.jackson.annotation.JsonProperty
import groovy.transform.ToString
import io.toro.linkedin.model.Company

/**
 * @author daniel.gomez
 */
@ToString(includeNames = true)
class CompanyAdminsResponse {
    @JsonProperty('_count')
    int count
    @JsonProperty('_start')
    int start
    @JsonProperty('_total')
    int total
    List&lt;Company&gt; values
}
</code></pre>