Using Custom Transcoder for N1QL Query


#1

Hey guys,
I want to use a custom transcoder to parse the N1QL results I get. (To directly have the JSON obj in my favourite lib).
By a quick look at the code, I see on N1qlQueryExecutor class that the JSON_OBJECT_TRANSCODER is hard coded as the transcoder for the query results.

Is there there any way of passing another transcoder ?
If not, are you guys plan to add this kind of behaviour ? (that would be fantastic! :slight_smile: )

Thanks,
Idan.


#2

Which client language / SDK are you using?


#3

Pretty sure it is Java!

Right now there is no way to change it, but we can investigate how much effort and API surface it would be!

@simonbasle wdyt?


#4

Btw, for now you can call toString on it for the raw JSON representation - of course a little more overhead than the real solution :smile:


Raw json document with n1ql in java sdk
#5

Hey, Thanks for the quick responses,
@daschl, Indeed it’s the Java SDK.
And calling the toString method and re-building the JSON obj is exactly what i’m trying to avoid :smile:

Would be great to save this overhead.


#6

Yeah, that’s what I figured - I opened a ticket to track this: https://issues.couchbase.com/browse/JCBC-869


#7

@idanna are you only interested in used your own unmarshalling for the individual rows?

if so, maybe what we could do is provide a β€œbyteValue()” method on (Async) N1qlQueryRow that will output byte[] instead of JsonObject, and have β€œvalue()” build upon this to expose the bytes as JsonObject.


#8

@simonbasle
That sounds fair enough!


#9

The feature will be available in 2.2.4, out February :smile: :thumbsup: