Use the @SerializedName annotation for ISO 3166-1

Our Java class needs to match the input JSON structure exactly, but
we can't use "3166-1" as a variable name so we tell GSON to use the
name "3166-1" when deserializing to countries.
This commit is contained in:
Alan Orth 2020-07-31 21:52:48 +03:00
parent 968bd354fe
commit f62b50f5a1
Signed by: alanorth
GPG Key ID: 0FB860CC9C45B1B9
2 changed files with 3 additions and 2 deletions

View File

@ -20,9 +20,10 @@ package org.cgiar.cgspace.ctasks;
import javax.annotation.Nullable;
import java.util.List;
import com.google.gson.annotations.SerializedName;
public class CountriesVocabulary {
List<Country> countries; //required
@SerializedName("3166-1") List<Country> countries; //required
class Country {
private String name; //required

View File

@ -82,7 +82,7 @@ public class CountryCodeTagger extends AbstractCurationTask
System.out.println(isocodesCountriesJson.getClass());
System.out.println(cgspaceCountriesJson.getClass());
for (CountriesVocabulary.Country country : cgspaceCountriesJson.countries) {
for (CountriesVocabulary.Country country : isocodesCountriesJson.countries) {
System.out.println(country.getName());
}