3

Call is successfully from below webservice although fields where JSON name contain underscore are omitted...being shown as null.

ShopifyProduct shopifyProducts = target.path( "admin" ).path( "products").queryParam("view","json").request( MediaType.APPLICATION_JSON_TYPE )
                            .header(HttpHeaders.AUTHORIZATION, basic ).accept( "application/json" )
                            .get( new GenericType<ShopifyProduct>(){});

BTW, I'm able to retrieve right data if I rename POJO field

@JsonProperty("body_html")
private String body_html;

I've tried unsuccessfully a couple of POJO configurations:

  1. Remove @JsonProperty and leave @JsonNaming
  2. Remove @JsonNaming and leave @JsonProperty

Jackson 2.8.7

Response

{
     "id": 9785936647,
     "title": "Product1",
     "body_html" : "<strong> description</strong>",
     "variants": [
        {
           "id": 37797111879,
           "product_id": 9785936647,
           "title": "Default Title",
        }
     ]
  }

POJO

@JsonIgnoreProperties( ignoreUnknown=true )
@JsonInclude( JsonInclude.Include.NON_EMPTY )
public class ShopifyProduct implements Serializable  {


private static final long serialVersionUID = 1L;

public ShopifyProduct() {
    // TODO Auto-generated constructor stub
}

@JsonProperty( "id" )
private Long id;

@JsonProperty( "title" )
private String title;

@JsonProperty( "body_html" )
private String bodyHtml;

....
....

//Getters and Setters
}

Result

    {
     "id": 9785936647,
     "title": "Product1",
     "body_html" : null,
     "variants": [
        {
           "id": 37797111879,
           "product_id": null,
           "title": "Default Title",
        }
     ]
  }

0 Answers0