How convert json object to string?

n1ql

#1

How can I convert json object to string object in N1QL,
such as

{"type":"test","name":"test_name1","members":["member1","member2"]}

So I can use “||” to concatenate the object to other string?


#2

Not sure I understand what you are trying to do here, can you tell us more?
From a more generic perspective, conversion functions are all described here: http://developer.couchbase.com/documentation/server/4.0/n1ql/n1ql-language-reference/typefun.html


#3

Hi, you can use the ENCODE_JSON() function:

SELECT ENCODE_JSON(obj)

obj can be any expression, including an object.


#4

OK, It works.I tried this function,but got null, It might be some logic issue.