public HmmModel deserialize(JsonElement json, Type type,
JsonDeserializationContext context) {
// register the builders for matrix / vector
GsonBuilder builder = new GsonBuilder();
builder.registerTypeAdapter(Matrix.class, new JsonMatrixAdapter());
builder.registerTypeAdapter(Vector.class, new JsonVectorAdapter());
Gson gson = builder.create();
// now decode the original model
JsonObject obj = json.getAsJsonObject();
String modelString = obj.get(MODEL).getAsString();
HmmModel model = gson.fromJson(modelString, HmmModel.class);