IGetResult get document as string

I am using the latest version of client (3.0.2). Thx for fixing serialization bootstrap.

But now i have another questions. In some place of my (code - in test if serialization works ok) I save document as object, but then I want read this document as string. (that was working in version 2.x). Is this bug or this will not be supported.

Error I got is
at Newtonsoft.Json.JsonTextReader.ReadStringValue(ReadType readType)
at Newtonsoft.Json.JsonTextReader.ReadAsString()
at Newtonsoft.Json.JsonReader.ReadForType(JsonContract contract, Boolean hasConverter)
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.Deserialize(JsonReader reader, Type objectType, Boolean checkAdditionalContent)
at Newtonsoft.Json.JsonSerializer.DeserializeInternal(JsonReader reader, Type objectType)
at Newtonsoft.Json.JsonSerializer.Deserialize(JsonReader reader, Type objectType)
at Newtonsoft.Json.JsonSerializer.Deserialize[T](JsonReader reader)
at Couchbase.Core.IO.Serializers.DefaultSerializer.Deserialize[T](ReadOnlyMemory1 buffer) at Couchbase.Core.IO.Transcoders.BaseTranscoder.DeserializeAsJson[T](ReadOnlyMemory1 buffer)
at Couchbase.Core.IO.Transcoders.JsonTranscoder.Decode[T](ReadOnlyMemory1 buffer, Flags flags, OpCode opcode) at Couchbase.KeyValue.GetResult.ContentAs[T]() at Shared.CouchbaseClient.CouchbaseClient.<GetWithCasAsync>d__311.MoveNext() in C:\Marg\4O_Backend\src\Lib.Shared\CouchbaseClient\CouchbaseClient.cs:line 457

Hi @luka,

Would you please post the code that leads to this error?

@luka -

The transcoding/serialization has changed from SDK2 to SDK3; this should work if you pass in the LegacyTranscoder as an option. Something like this:

var options = new GetAsync("key", options=>options.Transcoder(new LegacyTranscoder()); 

-Jeff

1 Like

Thank you. It Works.

Luka Por

2 Likes