@Override
	public Collection<Object> convert(String source) {
		Collection<Object> ruleCollection;

		// hard code
		if (ruleClass == FlowRule.class || ruleClass == DegradeRule.class
				|| ruleClass == SystemRule.class || ruleClass == AuthorityRule.class
				|| ruleClass == ParamFlowRule.class) {
			ruleCollection = new ArrayList<>();
		}
		else {
			ruleCollection = new HashSet<>();
		}

		if (StringUtils.isEmpty(source)) {
			log.info("converter can not convert rules because source is empty");
			return ruleCollection;
		}
		try {
			List sourceArray = objectMapper.readValue(source,
					new TypeReference<List<HashMap>>() {
					});

			for (Object obj : sourceArray) {
				try {
					String item = objectMapper.writeValueAsString(obj);
					Optional.ofNullable(convertRule(item))
							.ifPresent(convertRule -> ruleCollection.add(convertRule));
				}
				catch (IOException e) {
					log.error("sentinel rule convert error: " + e.getMessage(), e);
					throw new IllegalArgumentException(
							"sentinel rule convert error: " + e.getMessage(), e);
				}
			}
		}
		catch (Exception e) {
			if (e instanceof RuntimeException runtimeException) {
				throw runtimeException;
			}
			else {
				throw new RuntimeException("convert error: " + e.getMessage(), e);
			}
		}
		return ruleCollection;
	}
Convert sentinel rules for json or xml array Using strict mode to parse json or xml.

@author <a href="mailto:fangjian0423@gmail.com">Jim</a>
@see FlowRule
@see DegradeRule
@see SystemRule
@see AuthorityRule
@see ParamFlowRule
@see ObjectMapper
spring-cloud-alibaba-starters/spring-cloud-alibaba-sentinel-datasource/src/main/java/com/alibaba/cloud/sentinel/datasource/converter/SentinelConverter.java