Re: [basex-talk] Round tripping JSON

2015-08-04 Thread Marc van Grootel
Yes, I think it's a CACHERESTXQ bug. The handler I posted earlier triggers it. Not sure what exactly triggers it. Yes, if only we had a time machine. Kidding aside, REST services/microservices/UI clients/Javascript frameworks all are pushing on REST. I was triggered by recent developments by

Re: [basex-talk] Round tripping JSON

2015-08-04 Thread Marc van Grootel
Hi Christian, Super-fast as always ;-) I'm still struggling though. Couple of points I have this RESTXQ function that I'm trying to get working. declare %rest:POST({$query}) %rest:path(/json) %rest:consumes(application/json) %rest:produces(application/json)

Re: [basex-talk] Round tripping JSON

2015-08-04 Thread Christian Grün
Hi Marc, I can get this to work with %input:json format=direct/format=basic but when I change to format=map I still get [bxerr:BASX0003] Input could not be converted: POST.xml (Line 1): No text allowed before root element. Hm, it seems to work on my machine. Here is again the minimized

Re: [basex-talk] Round tripping JSON

2015-08-04 Thread Marc van Grootel
A last point I would like to make is that I still find it dubious that the client can specify things in a header (Content Type) that override the way it's porcessed on the server. Isn't this a case of The server knows best. As a client I just specify that this is JSON and leave it up to the server

Re: [basex-talk] Round tripping JSON

2015-08-04 Thread Marc van Grootel
I got it working using this function. One requirement though is that the client must send the JSON with a text content type or no content-type. This way the function receives a string argument and I can do with the string what I want. Not 100% satisfied because the client has to lie about it's

Re: [basex-talk] Round tripping JSON

2015-08-04 Thread Marc van Grootel
Hi Christian, I pulled it via the Maven repo using Gradle. It says BaseX 8.3 beta 7f8299f. Maybe that doesn't carry the latest? Re format name suggestions: format=item (not good, includes XML nodes), format=function (correct per http://www.w3.org/TR/xpath-datamodel-31/#types-representation as it

Re: [basex-talk] Round tripping JSON

2015-08-04 Thread Andy Bunce
This looks a bit like errors I have seen with CACHERESTXQ=true [1] and then hot swapping the XQuery files. Requesting /.init sorts it for me. /Andy [1] http://docs.basex.org/wiki/Options#CACHERESTXQ On 4 August 2015 at 10:05, Christian Grün christian.gr...@gmail.com wrote: All existing test

Re: [basex-talk] Round tripping JSON

2015-08-04 Thread Marc van Grootel
Thanks, came to that conclusion too, strange things is that CACHERESTXQ=true never bit me before. First time I have issues with it. I have it set to true almost all the time. --Marc On Tue, Aug 4, 2015 at 11:24 AM, Andy Bunce bunce.a...@gmail.com wrote: This looks a bit like errors I have seen

Re: [basex-talk] Round tripping JSON

2015-08-04 Thread Christian Grün
I got it working using this function. One requirement though is that the client must send the JSON with a text content type or no content-type. This way the function receives a string argument and I can do with the string what I want. So you mean that your clients will always send JSON as

Re: [basex-talk] Round tripping JSON

2015-08-04 Thread Marc van Grootel
Hi Christian, I figured it out. The way to repro is with the function I posted earlier. Start the server but with CACHERESTXQ=true. Test the function: works fine. Change the handler function/file and save it. Retry the POST, boom. NPE. Switching CACHERESTXQ=false no fixes this. About the

Re: [basex-talk] Round tripping JSON

2015-08-03 Thread Christian Grün
Hi Marc, declare %rest:POST({$body}) %rest:path(/json) %rest:consumes(application/json;lax=yes;format=map) %rest:produces(application/json;format=map) If I remember right, content-type parameters in rest annotations will be ignored, because these annotations only serve as filters.

Re: [basex-talk] Round tripping JSON

2015-08-03 Thread Marc van Grootel
Hi Christian, No luck. I'm using Postman. I already had Content-Type = application/json and Accept = application/json. I tried changing it to application/json;format=map (btw do you think it's necessary to have the basex/restxq specific pseudo attributes (format= etc) in the HTTP request

Re: [basex-talk] Round tripping JSON

2015-08-03 Thread Marc van Grootel
Wow, clicked send before I meant to. The last line was a copy from the table in the documentation and the last column has document-node() which seems to suggest that getting a map(*) there isn't possible. So not sure what is supposed to happen. Anyway I would think that correct behaviour would

Re: [basex-talk] Round tripping JSON

2015-08-03 Thread Christian Grün
Hi Marc, I'm using Postman. I already had Content-Type = application/json and Accept = application/json. I tried changing it to application/json;format=map I noticed that you get different result when specify 'format=basic' or 'format=direct': curl -XPUT

Re: [basex-talk] Round tripping JSON

2015-08-03 Thread Christian Grün
…fixed, and available via the latest snapshot [1]. Thanks, Christian [1] http://files.basex.org/releases/latest On Mon, Aug 3, 2015 at 5:11 PM, Christian Grün christian.gr...@gmail.com wrote: Hi Marc, I'm using Postman. I already had Content-Type = application/json and Accept =