Skip to content
Snippets Groups Projects
Commit 26e0a191 authored by Clayton, Brandon Scott's avatar Clayton, Brandon Scott
Browse files

read json

parent c0684bb2
No related branches found
No related tags found
1 merge request!266Report Version
package gov.usgs.earthquake.nshmp.internal; package gov.usgs.earthquake.nshmp.internal;
import java.io.IOException;
public interface AppVersion { public interface AppVersion {
public VersionInfo getVersionInfo() throws IllegalArgumentException; public VersionInfo getVersionInfo() throws IllegalArgumentException, IOException;
public static class VersionInfo { public static class VersionInfo {
public String branchName; public String branchName;
......
package gov.usgs.earthquake.nshmp.internal; package gov.usgs.earthquake.nshmp.internal;
import java.io.IOException;
import com.google.common.base.Charsets;
import com.google.common.io.Resources; import com.google.common.io.Resources;
import com.google.gson.Gson; import com.google.gson.Gson;
public class LibVersion implements AppVersion { public class LibVersion implements AppVersion {
public VersionInfo getVersionInfo() throws IllegalArgumentException { public VersionInfo getVersionInfo() throws IllegalArgumentException, IOException {
var resource = Resources.getResource("version.json"); var resource = Resources.getResource("version.json");
return new Gson().fromJson(resource.toString(), VersionInfo.class); return new Gson().fromJson(
Resources.toString(resource, Charsets.UTF_8),
VersionInfo.class);
} }
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment