我正在使用杰克逊 2.1.0。鉴于:
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/
时,Jackson 生成:
{"companies":["http://test.com/"]}
代替:
["http://test.com/"]
有任何想法吗?
更新:有关相关讨论,请参阅https://github.com/FasterXML/jackson-core/issues/41。