Convert json-xml module to use JSONiq items

Bug #1200090 reported by Chris Hillery
8
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Zorba
Fix Committed
Medium
Paul J. Lucas

Bug Description

The old "converters/json" module has been updated to be named "json-xml". However it still behaves the same way - converts between a couple different XDM forms (JsonML, Snelson) and JSON text. It would make more sense now for the inputs and outputs to be json-item()s instead:

declare function jx:xml-to-json($xml as item()*, $options as object()) as json-item()*

declare function jx:json-to-xml($json as json-item()*, $options as object()) as element(*,xs:untyped)*

(I'm not sure whether those should be json-item()* or just json-item() .)

Related branches

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

As discussed on the conf call, assigning to Paul to get his opinion on how large a task this would be. He would be the most reasonable person to implement this as well. Subscribing Ghislain so he can register his opinion on the exact API.

Changed in zorba:
assignee: nobody → Paul J. Lucas (paul-lucas)
milestone: none → 3.0
importance: Undecided → Medium
status: New → Confirmed
tags: added: module-cleanup
Revision history for this message
Paul J. Lucas (paul-lucas) wrote :

As I requested on the conf. call, please explain WHY it makes more sense now. What use cases does the proposed change make simpler? What cases does it make harder? If I already have an xs:string, how would I use json-to-xml() with the proposed change?

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

> please explain WHY it makes more sense now.

Because we have JSONiq now, and it's become a central part of the Zorba identity. It's weird (IMHO) to have a module in Zorba that deals with JSON only as strings, rather than data model instances.

> What use cases does the proposed change make simpler?

Any that involve getting JSON back from something (such as the new JSONiq-based http-client module, or the database drivers) and wanting to convert that to JsonML, etc. There are a great deal more ways of getting JSON data model instances than there are of getting JSON strings.

> What cases does it make harder?

If we leave the existing functionality in place (which is what I originally suggested), then nothing would become harder. The trick there is coming up with reasonable function names, since you can't really overload a single function name.

If we eliminate the JSON string functionality entirely (which is what Ghislain suggested), then any use case where you actually have only a JSON string would have one additional step. Also, it's possible that doing this might break streamability (does the module support that currently?).

> If I already have an xs:string, how would I use json-to-xml() with the proposed change?

jx:json-to-xml( jn:parse-json( $mystring ) )

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

Well, I could (for now) rename the string versions to include "string" in their names:

    json-string-to-xml()
    xml-to-json-string()

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

FYI: This is a LOT of work. About 25% done.

Changed in zorba:
status: Confirmed → In Progress
Changed in zorba:
status: In Progress → Fix Committed
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.