JsonML "No object allowed at this stage"

Friday, 2 October 2026 · 3 messages
BD
Bridger Dyson-Smith2 Oct 2026 17:21 #
Dear Christian, et al, Is this a bug or the usual user/operator error? While trying to add some parsed JSON to a database, I'm getting an error with BaseX 12.3 and json:parse($json, map {'format':'jsonml'}). I'm working on sample data from the COUNTER organization[1] - I've attached one of the sample files - and all of the format options work except for 'jsonml', which throws a 'No object allowed at this stage.' with the data. Is this an error on the BaseX side or a quirk with the JSON from the COUNTER org (or... most likely, I'm misunderstanding something!?)? Thanks for your helpful advice! Best, Bridger Code:
file:read-text("/home/bridger/Downloads/Sample-TR_J1.json") =>
json:parse(map{ "format": "jsonml" }),
(: returns 'No object allowed at this stage." :)

json:doc("/home/bridger/Downloads/Sample-TR_J1.json", map { "format":
"jsonml" })
(: returns 'No object allowed at this stage." :)
The BaseX GUI new database dialog throws the same error. I'll try to update my local BaseX, in case this has been addressed at some point.
CG
Christian Grün2 Oct 2026 19:58 #
Hi Bridger, thanks for the report. It's not a bug, and not a problem with the COUNTER data either. The jsonml format is meant for a different kind of input. JsonML is a way of writing XML documents as JSON arrays. Every element is an array: the element name comes first, then an optional object with the attributes, then the children:
["person", {"id": "1"}, "John"]
…becomes:
<person id="1">John</person>
So jsonml only accepts input in exactly this shape. Your COUNTER file is a regular JSON object, and the JsonML parser rejects an object at that position. That's what "No object allowed at this stage" is trying to say (admittedly not very clearly). For ordinary JSON like yours, any of the other formats will do. The default (direct) usually gives the most readable XML:
json:doc("/home/bridger/Downloads/Sample-TR_J1.json")
You can also use attributes, basic, or the standard json-to-xml function, whichever structure suits your queries best. Updating BaseX won't change the behavior, but we'll consider a clearer error message for this case. Best, Christian
Quoted text · Bridger Dyson-Smith · 33 lines
Bridger Dyson-Smith via BaseX-Talk <basex-talk at mailman.uni-konstanz.de> schrieb am Freitag, 2. Oktober 2026 um 17:23: > Dear Christian, et al, > > Is this a bug or the usual user/operator error? > > While trying to add some parsed JSON to a database, I'm getting an > error with BaseX 12.3 and json:parse($json, map {'format':'jsonml'}). > I'm working on sample data from the COUNTER organization[1] - I've > attached one of the sample files - and all of the format options work > except for 'jsonml', which throws a 'No object allowed at this stage.' > with the data. > > Is this an error on the BaseX side or a quirk with the JSON from the > COUNTER org (or... most likely, I'm misunderstanding something!?)? > > Thanks for your helpful advice! > Best, > Bridger > > Code: > ``` > file:read-text("/home/bridger/Downloads/Sample-TR_J1.json") => > json:parse(map{ "format": "jsonml" }), > (: returns 'No object allowed at this stage." :) > > json:doc("/home/bridger/Downloads/Sample-TR_J1.json", map { "format": > "jsonml" }) > (: returns 'No object allowed at this stage." :) > ``` > The BaseX GUI new database dialog throws the same error. > I'll try to update my local BaseX, in case this has been addressed at > some point. >
BD
Bridger Dyson-Smith2 Oct 2026 20:30 #
Hello Christian - Thank you so much for clarifying! I see now that I didn't properly read the JsonML description in the docs - I'm grateful for the correction. Have a great weekend! Best, Bridger
Quoted text · Christian Grün · 62 lines
On Fri, Oct 2, 2026 at 5:58 PM Christian Grün <cg at basex.org> wrote: > > Hi Bridger, > > thanks for the report. It's not a bug, and not a problem with the COUNTER data either. The jsonml format is meant for a different kind of input. > > JsonML is a way of writing XML documents as JSON arrays. Every element is an array: the element name comes first, then an optional object with the attributes, then the children: > > ["person", {"id": "1"}, "John"] > > …becomes: > > <person id="1">John</person> > > So jsonml only accepts input in exactly this shape. Your COUNTER file is a regular JSON object, and the JsonML parser rejects an object at that position. That's what "No object allowed at this stage" is trying to say (admittedly not very clearly). > > For ordinary JSON like yours, any of the other formats will do. The default (direct) usually gives the most readable XML: > > json:doc("/home/bridger/Downloads/Sample-TR_J1.json") > > You can also use attributes, basic, or the standard json-to-xml function, whichever structure suits your queries best. > > Updating BaseX won't change the behavior, but we'll consider a clearer error message for this case. > > Best, > Christian > > > Bridger Dyson-Smith via BaseX-Talk <basex-talk at mailman.uni-konstanz.de> schrieb am Freitag, 2. Oktober 2026 um 17:23: > > > Dear Christian, et al, > > > > Is this a bug or the usual user/operator error? > > > > While trying to add some parsed JSON to a database, I'm getting an > > error with BaseX 12.3 and json:parse($json, map {'format':'jsonml'}). > > I'm working on sample data from the COUNTER organization[1] - I've > > attached one of the sample files - and all of the format options work > > except for 'jsonml', which throws a 'No object allowed at this stage.' > > with the data. > > > > Is this an error on the BaseX side or a quirk with the JSON from the > > COUNTER org (or... most likely, I'm misunderstanding something!?)? > > > > Thanks for your helpful advice! > > Best, > > Bridger > > > > Code: > > ``` > > file:read-text("/home/bridger/Downloads/Sample-TR_J1.json") => > > json:parse(map{ "format": "jsonml" }), > > (: returns 'No object allowed at this stage." :) > > > > json:doc("/home/bridger/Downloads/Sample-TR_J1.json", map { "format": > > "jsonml" }) > > (: returns 'No object allowed at this stage." :) > > ``` > > The BaseX GUI new database dialog throws the same error. > > I'll try to update my local BaseX, in case this has been addressed at > > some point. > >

⚡Generated with XQuery