De-serialize a BO from JSON string.

@param json
the JSON string obtained from {@link #toJson(BaseBo)}
@param clazz
@return
346887
public static <T extends BaseBo> T fromJson(String json, Class<T> clazz) {
        return fromJson(json, clazz, null);
    }
932968
public static <T extends BasicMessage> T fromJSON(String json, Class<T> clazz) {
        try {
            Method buildObjectMapperForDeserializationMethod = findBuildObjectMapperForDeserializationMethod(clazz);

            final ObjectMapper mapper = (ObjectMapper) buildObjectMapperForDeserializationMethod.invoke(null);
            if (FailOnUnknownProperties.class.isAssignableFrom(clazz)) {
                mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, true);
            }

            return mapper.readValue(json, clazz);
        } catch (Exception e) {
            throw new IllegalStateException("JSON message cannot be converted to object of type [" + clazz + "]", e);
        }
    }
733647
public static JWEObject deserialize(String json) throws IOException {
        ObjectMapper mapper = new ObjectMapper();
        return mapper.readValue(json, JWEObject.class);
    }
976745
@SuppressWarnings("unchecked")
    public BaseBo fromJson(String jsonString) {
        Map<String, Object> dataMap = null;
        try {
            dataMap = jsonString != null ? SerializationUtils.fromJsonString(jsonString, Map.class)
                    : null;
        } catch (Exception e) {
            dataMap = null;
        }
        return fromMap(dataMap);
    }
123101
public <T> T parse(JsonObject obj, Class<T> clazz) {
        return gson.fromJson(obj, clazz);
    }
1021925
public static CompleteRestoreBridgeResult deserialize(String json) {
        JaxbJsonSerializer<CompleteRestoreBridgeResult> serializer =
            new JaxbJsonSerializer<>(CompleteRestoreBridgeResult.class);
        try {
            return serializer.deserialize(json);
        } catch (IOException e) {
            throw new SnapshotDataException(
                "Unable to create result due to: " + e.getMessage());
        }
    }
473992
public static <T> Optional<T> toBean(String json, Class<T> clazz) {
        if (StringUtils.isBlank(json)) {
            log.warn("json is blank. ");
            return Optional.empty();
        }
        try {
            OBJECT_MAPPER.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
            return Optional.of(OBJECT_MAPPER.readValue(json, clazz));
        } catch (Exception e) {
            log.error(e.getMessage(), e);
            return Optional.empty();
        }
    }
990369
public static String convertSerializableToString(Serializable obj) {
        ByteArrayOutputStream baos = null;
        ObjectOutputStream oos = null;
        try {
            baos = new ByteArrayOutputStream();
            oos = new ObjectOutputStream(baos);
            oos.writeObject(obj);

            return new String(baos.toByteArray());
        } catch (IOException e) {
            return null;
        } finally {
            closeQuietly(baos, oos);
            closeQuietly(oos);
        }
    }
1163148
public static SearchBuilder fromJson(String json) {
        try {
            return JsonSerializer.fromString(json, SearchBuilder.class);
        } catch (IOException e) {
            return SearchBuilderLegacy.fromJson(json);
        }
    }
1183190
public static Parameters fromJson(String json) {
		Map<String, Object> map = JsonConverter.toNullableMap(json);
		return map != null ? new Parameters(map) : new Parameters();
	}
842384
@SneakyThrows
    public static <T> T deserialize(final InputStream inputStream, final Class<T> clazz) {
        try (val in = new ObjectInputStream(inputStream)) {
            val obj = in.readObject();

            if (!clazz.isAssignableFrom(obj.getClass())) {
                throw new ClassCastException("Result [" + obj
                    + " is of type " + obj.getClass()
                    + " when we were expecting " + clazz);
            }
            return (T) obj;
        }
    }
735886
public void convertToTypes( String serialization, Class<?> clazz, JsonObject newDef ) {
		convertToTypes( serialization, clazz.getSimpleName(), newDef );
		this.processedClasses.add( clazz );
	}
415855
public static <T> T toObject(String json, Class<T> clazz) {
        if (json == null || json.trim().length() == 0) {
            return null;
        }
        T t = null;
        try {
            t = JSON.parseObject(json, clazz);
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
        return t;
    }
754847
@Override
    public String serialize(T element) {
        String json = null;
        try {
            json = element.toJSON();
        } catch (Exception e) {
            log.error("Direct serialization failed, falling back to jackson");
        }

        if (json == null || json.isEmpty()) {
            ObjectMapper mapper = SequenceElement.mapper();
            try {
                json = mapper.writeValueAsString(element);
            } catch (org.nd4j.shade.jackson.core.JsonProcessingException e) {
                throw new RuntimeException(e);
            }
        }

        return json;
    }
343
@Override
	public <T> T toObject(String json, Class<T> clazz) {
		return toObject(json, clazz, false);
	}
1353352
public <T> List<T> fromJsons(String jsons, Class<T> clazz) throws IOException {
        if (jsons == null || jsons.trim().length() == 0) {
            return Collections.EMPTY_LIST;
        }

        List<T> list = new ArrayList<>();

        JsonNode jsonNode = mapper.readTree(jsons);
        if (jsonNode.isArray()) {//是数组
            for (JsonNode child : jsonNode) {
                list.add(mapper.treeToValue(child, clazz));
            }
        } else {//不是数组
            list.add(fromJson(jsons, clazz));
        }

        return list;

    }
139462
@Nullable
    public String toJson(@Nullable Map<String, Object> map) {
        if (map == null || map.isEmpty()) {
            return null;
        }

        try (StringWriter writer = new StringWriter(bufferSize)) {
            objectMapper.writeValue(writer, map);
            if (doesAppendLineSeparator) {
                writer.append(CoreConstants.LINE_SEPARATOR);
            }
            return writer.toString();
        } catch (IOException e) {
            throw new IllegalArgumentException("Unable to format map as a JSON", e);
        }
    }