json 2.0 bug: wrong behavior for parsing empty value

Bug #920721 reported by Sorin Marian Nasoi
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Zorba
Fix Released
Medium
Paul J. Lucas

Bug Description

Parsing an empty value has wrong behavior for both JSON mappings (Snelson and JSON-ML).
Please see failing tests:
- test/rbkt/zorba/json/json-snelson-empty-value
- test/rbkt/zorba/json/json-jsonml-empty-value

For instance in zorba/json/json-snelson-empty-value.xq:

import module namespace json = "http://www.zorba-xquery.com/modules/converters/json";
json:parse(<a/>)

Should raise error(s) http://www.zorba-xquery.com/errors:ZJPE0001
But instead Zorba returns a result.

For test/rbkt/zorba/json/json-jsonml-empty-value.xq:

import module namespace json = "http://www.zorba-xquery.com/modules/converters/json";
let $options :=
  <options xmlns="http://www.zorba-xquery.com/modules/converters/json-options">
    <json-format value="JsonML-array"/>
  </options>
json:parse(<a/>,$options)

Zorba returns http://www.w3.org/2005/xqt-errors:XPST0003
instead of http://www.zorba-xquery.com/errors:ZJPE0001

Revision history for this message
Paul J. Lucas (paul-lucas) wrote :

Renamed the tests to conform to all the rest, i.e., contain "parse" or "serialize" in the test name. Also, again, the second test is invalid XQuery since it's missing a "return".

Revision history for this message
Paul J. Lucas (paul-lucas) wrote :

These functions are declared as taking an xs:string? as an argument. If one is able to pass something like <a/> (which is not a string), then it points to a bug elsewhere in the code, i.e., something should have checked that the actual argument type doesn't match the declared argument type -- right? If so, that's not my code.

Revision history for this message
Paul J. Lucas (paul-lucas) wrote :

What specification tells you that parsing an empty value should return an error?
Why isn't returning nothing valid?

Revision history for this message
Chris Hillery (ceejatec) wrote :

The JSON grammar is not as pedantic as I would like, but it looks like a JSON text must be exactly an object or an array.

  http://tools.ietf.org/html/rfc4627

So an empty string is not a valid instance of JSON.

Changed in zorba:
status: New → Fix Committed
Changed in zorba:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.