以下json的类型为java.util.HashMap
<xsl:for-each select="$itemContent/item">
<xsl:sort select="pub-date" order="descending"/>
<xsl:if test="position() mod $group-size = 1">
<div class="item">
<xsl:if test="position()=1">
<xsl:attribute name="class">item active</xsl:attribute>
</xsl:if>
<ul>
<xsl:apply-templates select=".|following-sibling::item[position() < $group-size]" mode="list"/>
</ul>
</div>
</xsl:if>
</xsl:for-each>
<xsl:template match="item">
<xsl:if test="position() mod $group-size = 1">
<ul>
<xsl:apply-templates select=".|/following::item[position() < $group-size]" mode="list"/>
</ul>
</xsl:if>
</xsl:template>
<xsl:template match="item" mode="list">
<li class="{position()}">
<strong><a href="{url}"><xsl:value-of select="title" /> | <xsl:value-of select="position()" /></a></strong><br/>
<xsl:value-of select="format-date(ou:get-xsdate(pub-date),'[FNn] [MNn] [D], [Y]', 'en', (), ())" />
</li>
</xsl:template>
我试图在groovy中使用jsonRequest = jsonRequest.remove(“premiumList”)从下面的地图中删除premiumList。
当我打印jsonRequest时,它将输出显示为
jsonRequest=[noOfMembers:2, coverageYear:2017, zipCode:99123, premiumList:[[Premium:203.05, Id:1000101], [Premium:205.36, Id:1000102], [Premium:207.67, Id:1000103], [Premium:209.98, Id:1000104], [Premium:212.29, Id:1000105]], members:[[id:5487, age:34, gender:M], [id:5488, age:32, gender:F]]]
如何在groovy中从地图中删除整个premiumList?
答案 0 :(得分:2)
即使您的java.util.HashMap
为hashmap
并且您尝试删除密钥,也需要知道jsonRequest
来自何处。 AFIK,你试图从请求中删除一个不允许删除的密钥?
def jsonRequest = [noOfMembers:2, coverageYear:2017, zipCode:99123, premiumList:[[Premium:203.05, Id:1000101], [Premium:205.36, Id:1000102], [Premium:207.67, Id:1000103], [Premium:209.98, Id:1000104], [Premium:212.29, Id:1000105]], members:[[id:5487, age:34, gender:M], [id:5488, age:32, gender:F]]]
def output = [:] << jsonRequest
output.remove('premiumList')