JsonFieldParser { public Field parse(JSONObject jsonObject, String id) throws JSONException { String type = jsonObject.getString("type"); final String name = jsonObject.getString("name"); final Object valueObject = jsonObject.opt(VALUE_ATTRIBUTE); final Object value; if ("comment".equals(name)) { type = "com.atlassian.jira.Comment"; } if (valueObject == null) { value = null; } else { final JsonParser valueParser = registeredValueParsers.get(type); if (valueParser != null) { value = valueParser.parse(jsonObject); } else { value = valueObject.toString(); } } return new Field(id, name, type, value); }  Field parse(JSONObject jsonObject, String id);  }
@Test public void testParse() throws Exception { JsonFieldParser parser = new JsonFieldParser(); final JSONObject fieldsJs = ResourceUtil.getJsonObjectFromResource("/json/field/valid-fields.json"); final Field field = parser.parse(fieldsJs.getJSONObject("customfield_10000"), "customfield_10000"); assertEquals(1.45, (Double) field.getValue(), 0.001); final Field userField = parser.parse(fieldsJs.getJSONObject("customfield_10020"), "customfield_10020"); assertEquals(TestConstants.USER1, userField.getValue()); }