Using a raw json string for mutate-in value


#1

Hi,

we use a custom JSON serializer so we create documents using the RawJsonDocument. We would like to use the sub-document API from the Java SDK to insert JSON fragments into existing documents, e.g. {“abc” : “def”, “ghi” : “jkl”}. I tried the mutate-in operation providing it with the JSON fragment as a String, but it inserted {\“abc\” : \“def\”, \“ghi\” : \“jkl\”} so it obviously treated it like a plain String. Everything was inserted ok when I used a JsonObject as the value, but that in our case means two conversions (POJO -> JSON String -> JSONObject), which we would like to avoid. Is there please a way to insert JSON fragments as a raw JSON string using the sub-document API? Btw, I’ve found a blog post

https://blog.couchbase.com/subdoc-explained/

where I can see it as an example in some pseudo-code

bucket.mutate_in('customer123',
                 SD.upsert('phone.home',
                           {'num': '775-867-5309', 'ext': 16},
                           create_parents=True))

Thanks in advance for any help!


#2

The example you have found is not pseudo code, it is python code.