8
我正在使用Jackson 2.1.0。鑑於:爲什麼@JsonUnwrapped不能用於列表?
public static final class GetCompanies
{
private final List<URI> companies;
/**
* Creates a new GetCompanies.
* <p/>
* @param companies the list of available companies
* @throws NullPointerException if companies is null
*/
@JsonCreator
public GetCompanies(@JsonUnwrapped @NotNull List<URI> companies)
{
Preconditions.checkNotNull(companies, "companies");
this.companies = ImmutableList.copyOf(companies);
}
/**
* @return the list of available companies
*/
@JsonUnwrapped
@SuppressWarnings("ReturnOfCollectionOrArrayField")
public List<URI> getCompanies()
{
return companies;
}
}
當輸入列表包含http://test.com/
,傑克遜生成:
{"companies":["http://test.com/"]}
代替:
["http://test.com/"]
任何想法?
UPDATE:有關相關討論,請參閱https://github.com/FasterXML/jackson-core/issues/41。