Thanks.I will run some performance tests to decide for json:serialize or PHP internal conversion which might be considerably slower.
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>, map { 'format': 'jsonml' } )