Hi Paul, no need to despair ;)
The default JSON converter is the direct one (which would require <testId/> to be declared an object), not JsonML. If you you want to use JsonML you can do so by using json:serialize( <json type="array" objects='_'>{ for $user in collection("saveresult")//user[_id="1f2cda8f-a18a-44ba-8d17-73626d472306"] return <_> <testId>{$user/test/_id}</testId> <grade>{$user/user_info/user_grade}</grade> </_> }</json>, map { 'format': 'jsonml' } ) For some more information you can take a look at https://docs.basex.org/wiki/JSON_Module Cheers, Dirk On 11/07/14 12:13, Paul Swennenhuis wrote: > Still no luck: > JSON serializer: <testId> is typed as "string" and cannot be nested > > I think I am going to move the JSON conversion to within PHP or > Javascript, and keep the XQueries clean and readable. > > Paul >> json:serialize( >> <json type="array" objects='_'>{ >> for $user in >> collection("saveresult")//user[_id="1f2cda8f-a18a-44ba-8d17-73626d472306"] >> >> return >> <_> >> <testId>{$user/test/_id}</testId> >> <grade>{$user/user_info/user_grade}</grade> >> </_> >> }</json> >> ) > -- Dirk Kirsten, BaseX GmbH, http://basex.org |-- Firmensitz: Blarerstrasse 56, 78462 Konstanz |-- Registergericht Freiburg, HRB: 708285, Geschäftsführer: | Dr. Christian Grün, Dr. Alexander Holupirek, Michael Seiferle `-- Phone: 0049 7531 28 28 676, Fax: 0049 7531 20 05 22