我有一个宁静的Web服务(JAVA),它必须接受JSON请求.我必须首先针对我拥有的JSON模式验证此JSON.我不确定什么是最好的JAVA库来再次验证JSON JSON模式.我使用了json-schema-validator -2.1.7库,但它并没有太大帮助.即使我认为我的JSON不是有效的JSON我也没有任何错误.
这是我用于json-schema-validator-2.1.7的代码
InputStream jsonSchemaInputStream = Assessment.class.getClassLoader().getResourceAsStream("Schemas/AssessmentMetrics.json");
ObjectMapper mapper = new ObjectMapper();
// Allows to retrieve a JSONSchema object on various sources
// supported by the ObjectMapper provided
JSONSchemaProvider schemaProvider = new JacksonSchemaProvider(mapper);
// Retrieves a JSON Schema object based on a file
JSONSchema schema = schemaProvider.getSchema(jsonSchemaInputStream);
// Validates a JSON Instance object stored in a file
List<String> errors = schema.validate(contents);
Run Code Online (Sandbox Code Playgroud) I have 2 xml files which I need to merge together using a style sheet
<AssessmentInput>
<ApplicationData>...</AppicationData>
<MetricList>...</MetricList>
</AssessmentInput>
Run Code Online (Sandbox Code Playgroud)
One is ApplicationData and the other one is MetricList. here is what I have done but it is nothing close to what it should be
<?xml version="1.0" encoding="ascii"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:exslt="http://exslt.org/common" exclude-result-prefixes="xsl exslt">
<xsl:output omit-xml-declaration="yes" method="xml" encoding="UTF-8"/>
<xsl:param name="ApplicationData" select="/"/>
<xsl:param name="MetricList"/>
<xsl:template match="/">
<xsl:apply-templates select="$ApplicationData/ApplicationData"/>
</xsl:template>
<xsl:template match="ApplicationData">
<xsl:copy>
<xsl:apply-templates select="@*"/>
<xsl:apply-templates select="*"/>
</xsl:copy>
</xsl:template>
<xsl:template match="@* | node()"> …Run Code Online (Sandbox Code Playgroud)