-
Notifications
You must be signed in to change notification settings - Fork 12
Description
The specification says:
https://www.w3.org/TR/xpath-functions-31/#func-parse-json
The effect of the one-argument form of this function is the same as calling the two-argument form with an empty map as the value of the $options argument.
And the escape parameter says Default: true
I read this as saying that if parse-json is called without a map as second parameter JSON escaping is to take place.
But parse-json-028 to parse-json-031 all seem to assume that escape is false:
<test>parse-json('["\\"]')</test>
<result>
<all-of><assert>$result?1 = "\"</assert>
<assert>$result?1 instance of xs:string</assert></all-of>
</result>
\\ in JSON is \. If escape is set to true, then JSON escape sequences should appear in the result. There are tests for this when it's set explicitly to true, such as fn-parse-json-035.
The tests assume either a different default for escape than the specification mandates, or the default is different for the single parameter form of parse-json.
P.S. The specification assumes rather particular things about JSON handling. The Rust json crate is a reasonable implementation of the spec, but it makes liberal meaningless, makes duplicates impossible to implement correctly (use-last is always in use, which the JSON RFC says is a common compatible interpretation), and JSON escaping rules are handled so that by the time I get a string, I need to re-escape it again in order to follow this specification. It also mystifies me why escaped JSON characters in the item result should ever be desirable.