I am facing a problem with the N1QL when using the * (star) in the query which fetches all the fields of the document. The result of using such * in the query returns below -
I have highlighted the unwanted naming in the json structure. This happens only when I use the * in the query. If I uset he field names to define my result, then it does not add this name to the nodes.
It is really getting difficult to deserialize the json when this node name gets added.
When I fire a N1QL query using the .NET SDK - Bucket.Query(“SELECT …”), I am able to receive the deserialized object back. Is there any option to get a plain json string as I see in your tutorial. Sometimes it is preferred to operate on the Json stream rather than doing a serialization & Deserialization.
I am actually getting the object and serializing it into string .NET. But its a kind of double processing. Couchbase SDK deserializes the json string and gives it to me as an object and then I do a serialization to change it back to string. Just thought of checking if there is any option to just get string output with the query.
I don’t think there is a way as is.
We extract the “result” part of the response into the Rows collection and let Json.NET do the mapping to the provided generic type. More accurately, we use Json.NET to map the entire response to a POCO that has a List<T> of rows for the results section.
Attempting to use string for T here instead of dynamic won’t cut it since in this case Json.NET expects a JSON string and finds a JSON object.
I’m not aware of a pseudo-type that could be used for T in order to bypass unmarshalling, but maybe Json.NET provides one? This would be outside the scope of the SDK though…