将Json转换成对象.

@param json
@param valueType
@return
343
@Override
	public <T> T toObject(String json, Class<T> clazz) {
		return toObject(json, clazz, false);
	}
609896
public String getStringFrom(JsonValue json) {
    if (json.isString()) {
      return json.asString();
    } else {
      return json.toString();
    }
  }
136734
public Result json() {
        setContentType(MimeTypes.JSON);
        charset = Charsets.UTF_8;
        // If we already have a String content, we must set the type.
        // The renderable object checks whether or not the given String is a valid JSON string,
        // or if a transformation is required.
        if (getRenderable() instanceof RenderableString) {
            ((RenderableString) getRenderable()).setType(MimeTypes.JSON);
        }
        return this;
    }
1059346
private JsonElement parseJsonObjectType(JsonSchema schema, JsonElement value)
      throws DataConversionException {
    JsonSchema valuesWithinDataType = schema.getValuesWithinDataType();
    if (schema.isType(MAP)) {
      if (Type.isPrimitive(valuesWithinDataType.getType())) {
        return value;
      }

      JsonObject map = new JsonObject();
      for (Entry<String, JsonElement> mapEntry : value.getAsJsonObject().entrySet()) {
        JsonElement mapValue = mapEntry.getValue();
        map.add(mapEntry.getKey(), parse(mapValue, valuesWithinDataType));
      }
      return map;
    } else if (schema.isType(RECORD)) {
      JsonSchema schemaArray = valuesWithinDataType.getValuesWithinDataType();
      return parse((JsonObject) value, schemaArray);
    } else {
      return JsonNull.INSTANCE;
    }
  }
46446
public static CmsClientAliasImportResult parse(JSONObject json) {

        String line = getString(json, JSON_LINE);
        String message = getString(json, JSON_MESSAGE);
        String statusStr = getString(json, JSON_STATUS);
        CmsAliasImportStatus status = CmsAliasImportStatus.valueOf(statusStr);
        return new CmsClientAliasImportResult(line, status, message);
    }
289826
@SuppressWarnings("unchecked")
	public <T> T toObject(String jsonString, JavaType javaType) {
		if (StringUtils.isEmpty(jsonString)) {
			return null;
		}

		try {
			return (T) mapper.readValue(jsonString, javaType);
		} catch (IOException e) {
			throw new RuntimeException(e);
		}
	}
434309
public Datatype.Builder setValueType(TypeClass valueType) {
    this.valueType = Objects.requireNonNull(valueType);
    _unsetProperties.remove(Property.VALUE_TYPE);
    return (Datatype.Builder) this;
  }
1329490
public static DataAnalysis fromJson(String json) {
        try{
            return new JsonSerializer().getObjectMapper().readValue(json, DataAnalysis.class);
        } catch (Exception e){
            //Legacy format
            ObjectMapper om = new JsonSerializer().getObjectMapper();
            return fromMapper(om, json);
        }
    }
216135
public static <T> T fromJson(final String json, final JavaType type) {
        try {
            return createObjectMapper().readValue(json, type);
        } catch (Exception e) {
            throw new ParseException(e);
        }
    }
414123
public static String getDatatypeIriFromJsonDatatype(String jsonDatatype) {
		switch (jsonDatatype) {
		case JSON_DT_ITEM:
			return DT_ITEM;
		case JSON_DT_PROPERTY:
			return DT_PROPERTY;
		case JSON_DT_GLOBE_COORDINATES:
			return DT_GLOBE_COORDINATES;
		case JSON_DT_URL:
			return DT_URL;
		case JSON_DT_COMMONS_MEDIA:
			return DT_COMMONS_MEDIA;
		case JSON_DT_TIME:
			return DT_TIME;
		case JSON_DT_QUANTITY:
			return DT_QUANTITY;
		case JSON_DT_STRING:
			return DT_STRING;
		case JSON_DT_MONOLINGUAL_TEXT:
			return DT_MONOLINGUAL_TEXT;
		default:
			if(!JSON_DATATYPE_PATTERN.matcher(jsonDatatype).matches()) {
				throw new IllegalArgumentException("Invalid JSON datatype \"" + jsonDatatype + "\"");
			}

			String[] parts = jsonDatatype.split("-");
			for(int i = 0; i < parts.length; i++) {
				parts[i] = StringUtils.capitalize(parts[i]);
			}
			return "http://wikiba.se/ontology#" + StringUtils.join(parts);
		}
	}
86499
public static Option fromJSON(String json) {
        Gson gson = new GsonBuilder().setPrettyPrinting().
                registerTypeAdapter(Series.class, new SeriesDeserializer()).
                registerTypeAdapter(Axis.class, new AxisDeserializer()).create();
        Option option = gson.fromJson(json, Option.class);
        return option;
    }
868864
public JSONObject getJson() throws JSONException {
        JSONObject json = create();
        if (value != null)
            json.put("value", value);
        if (label != null)
            json.put("label", label);
        if (type != null)
            json.put("type", type);
        if (display != null)
            json.put("display", display.toString());
        if (sequence != 0)
            json.put("sequence", sequence);
        if (indexKey != null)
            json.put("indexKey", indexKey);
        return json;
    }
145529
public static final SerIterable set(final Class<?> valueType, final List<Class<?>> valueTypeTypes) {
        final Set<Object> coll = new HashSet<>();
        return set(valueType, valueTypeTypes, coll);
    }
285515
public JaversBuilder registerValueGsonTypeAdapter(Class valueType, TypeAdapter nativeAdapter) {
        registerValue(valueType);
        jsonConverterBuilder().registerNativeTypeAdapter(valueType, nativeAdapter);
        return this;
    }
724771
function (instance, instanceKey, type, json, jsonKey) {
    try {
        instance[instanceKey] = json[jsonKey];
        return [];
    }
    catch (e) {
        // tslint:disable-next-line:no-string-literal
        throw new JsonConverstionError("Property '" + instanceKey + "' of " + instance.constructor['name'] + " does not match datatype of " + jsonKey, json);
    }
}
1143639
public static <T extends Option> T fromJSON(String json, Class<T> type) {
        Gson gson = new GsonBuilder().setPrettyPrinting().
                registerTypeAdapter(Series.class, new SeriesDeserializer()).
                registerTypeAdapter(Axis.class, new AxisDeserializer()).create();
        return gson.fromJson(json, type);
    }
520098
public static Schema fromJson(String json) {
        try{
            return JsonMappers.getMapper().readValue(json, Schema.class);
        } catch (Exception e){
            //TODO better exceptions
            throw new RuntimeException(e);
        }
    }