json:serialize returns invalid json

Bug #900462 reported by Matthias Brantner
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Zorba
Fix Released
Critical
Sorin Marian Nasoi

Bug Description

The json:serialize function returns syntactically incorrect json.

For example, the existing test query serialize_json_18.xq fails because it's missing an ending curly '}' as follows:

import module namespace json = "http://www.zorba-xquery.com/modules/converters/json";
import schema namespace html-options="http://www.zorba-xquery.com/modules/converters/json-options";

declare variable $tmp := <json type="object"><pair name="phoneNumbers" type="array"><item type="string">212 732-1234</item><item type="string">646 123-4567</item></pair><pair name="firstName" type="string">John</pair><pair name="lastName" type="string">Smith</pair><pair name="address" type="object"><pair name="postalCode" type="number">10021</pair><pair name="city" type="string">New York</pair><pair name="streetAddress" type="string">21 2nd Street</pair><pair name="state" type="string">NY</pair></pair></json>;

json:serialize($tmp)

Actual: <<root>{"phoneNumbers": ["212 732-1234", "646 123-4567"], "firstName": "John", "lastName": "Smith", "address": {"postalCode": 10021, "city": "New York", "streetAddress": "21 2nd Street", "state": "NY"}</root>>

Expected: <<root>{"phoneNumbers": ["212 732-1234", "646 123-4567"], "firstName": "John", "lastName": "Smith", "address": {"postalCode": 10021, "city": "New York", "streetAddress": "21 2nd Street", "state": "NY"}}>

Related branches

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

Why is this my bug? I'm not going to spend any time fixing the old JSON parser.

Changed in zorba:
status: New → Won't Fix
Changed in zorba:
status: Won't Fix → New
assignee: Paul J. Lucas (paul-lucas) → Sorin Marian Nasoi (sorin.marian.nasoi)
Changed in zorba:
status: New → Fix Committed
Changed in zorba:
status: Fix Committed → In Progress
Revision history for this message
Matthias Brantner (matthias-brantner) wrote :

Also, a similar error occurs if a json error is serialized. In this case, the closing ']' is missing.

Revision history for this message
Sorin Marian Nasoi (sorin.marian.nasoi) wrote :

Fixed is in the merge proposal.

Changed in zorba:
status: In Progress → Fix Committed
milestone: 2.2 → none
milestone: none → 2.1
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.