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 text/plain or without content type? In that case, you can indeed use json:parse($input).
Not 100% satisfied because the client has to lie about it's content type in order to get this to work.
I need to ask for more details: Do you want to say that you are bothered by the implicit JSON conversion once the user specifies the content-type? Would you like to have disabled this conversion?
although the HTTP specs more or less allow it many tools and libraries (including BaseX/RESTXQ) do not support sending bodies with GET. So now I'm doing this with POST which feels wrong too.
In that case, Elasticsearch seems to have deviated from Roy Field's initial suggestions, which seem to also have been adopted by JAX-RS and, consistently, RESTXQ (see e.g. [1]).
[1] https://groups.yahoo.com/neo/groups/rest-discuss/conversations/messages/9962