Actions
Bug #4826
closedIndentation inconsistency when serializing JSON
Start date:
2020-11-16
Due date:
% Done:
100%
Estimated time:
Legacy ID:
Applies to branch:
10, trunk
Fix Committed on Branch:
10, trunk
Fixed in Maintenance Release:
Platforms:
Description
I have this code:
...
<xsl:for-each select="1 to 6">
<xsl:variable name="fields" select="$block/fields/ES_KALEIDOSCOPEFIELD[@fieldNumber = current()]"/>
<xsl:sequence
select="map{'field' || current(): map{
'field': mgx:join($fields//@value),
'color': mgx:join($fields//@htmlvalue!concat('#', .))
}}"
/>
</xsl:for-each>
<xsl:function name="mgx:join" as="xs:string?">
<xsl:param name="values" as="xs:string*"/>
<xsl:sequence select="if(empty($values)) then () else $values => string-join(' ')"/>
</xsl:function>
When serializing this to JSON, it seems there is a difference in indentation if one of the values is null instead of a string:
"field3": {
"color": "#FF8080",
"field": "Purchase" },
"field4": {
"color": null,
"field": null
},
"field5": {
"color": "#FFC080",
"field": "Sport - other" },
Not a big deal of course, but it looks a bit off. I think the most common way of indenting a JSON object is to put the ending curly bracket on a separate line (the way field4 is displayed).
Please register to edit this issue
Actions