[basex-talk] JSON output in PHP client

2014-07-11 Thread Paul Swennenhuis
I've been playing a bit with BaseX the last couple of days - and very excited about the product while doing so - but now I am having problems outputting JSON from a PHP script. I have this XQuery: declare option output:method json; declare option output:json format=jsonml; json type=object {

Re: [basex-talk] JSON output in PHP client

2014-07-11 Thread Christian Grün
Hi Paul, Which is what I expected after reading about the JSONML format. (Not too happy with that format, but that's another story). I agree; JSONML is a quasi-standard we have adopted, which is mainly useful for converting arbitrary XML to JSON. If you can decide how your XML format looks

Re: [basex-talk] JSON output in PHP client

2014-07-11 Thread Paul Swennenhuis
Hi Christian, Thanks for the quick answer. Unfortunately your proposed solution (json:serialize) does not work in this case; BaseX returns a BXJS0002 error: JSON serializer: found, _ expected. The modified query reads: json:serialize( json type=array objects='_'{ for \$user in

Re: [basex-talk] JSON output in PHP client

2014-07-11 Thread Christian Grün
I should have run your query before sending you an answer. The following query should work: json:serialize( json type=array objects='_'{ for $user in collection(saveresult)//user[_id=1f2cda8f-a18a-44ba-8d17-73626d472306] return _ testId{$user/test/_id}/testId

Re: [basex-talk] Distributed features in BaseX

2014-07-11 Thread Sergey Alekhin
Hello, If distributed storage implemented via NFS (Network file system), the answer should be yes. For example, folder /opt/strage/data1/. maps to server1, another folder /opt/storage/data2/. maps to server2, distributed query might look like this: let $A :=

Re: [basex-talk] JSON output in PHP client

2014-07-11 Thread Paul Swennenhuis
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

Re: [basex-talk] JSON output in PHP client

2014-07-11 Thread Dirk Kirsten
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

Re: [basex-talk] Distributed features in BaseX

2014-07-11 Thread Dirk Kirsten
Hello Chen, at the moment, the answer to this question is still no. We are working into this direction, but we are not production ready. As Sergey outlines you can of course use a distributed file system as basis for BaseX. Cheers, Dirk On 11/07/14 11:59, Sergey Alekhin wrote: Hello,

Re: [basex-talk] JSON output in PHP client

2014-07-11 Thread Paul Swennenhuis
Ah, yes, that did the trick. I read about the options but had forgotten about it. 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

Re: [basex-talk] JSON output in PHP client

2014-07-11 Thread Christian Grün
Hi Paul, and thanks Dirk. One last note: If you plan to stick with JsonML, you can serialize arbitrary XML data, such as.. json:serialize( xml{ for $user in collection(saveresult)//user[_id=1f2cda8f-a18a-44ba-8d17-73626d472306] return result