private static BeanstreamResponse fromJson(int httpStatusCode, String jsonPayload, MediaType responseType) {

        JsonParser parser = new JsonParser();
        JsonObject json = parser.parse(jsonPayload).getAsJsonObject();
        BeanstreamResponseBuilder builder = new BeanstreamResponseBuilder();

        builder.setMediaType(responseType);
        
        // for now, need to guard for nulls
        JsonElement element = null;
        element = json.get("code");
        if (!element.isJsonNull()) {
            builder.withCode(element.getAsInt());
        }

        element = json.get("category");
        if (!element.isJsonNull()) {
            builder.withCategory(element.getAsInt());
        }

        element = json.get("message");
        if (!element.isJsonNull()) {
            builder.withMessage(element.getAsString());
        }

        element = json.get("reference");
        if (!element.isJsonNull()) {
            builder.withReference(element.getAsString());
        }
        
        element = json.get("details");
        if (element != null && !element.isJsonNull()) {
            builder.withDetails(element.toString());
        }

        builder.withHttpStatusCode(httpStatusCode);
        return builder.build();
    }