1

So the problem is like below, I have a table which has a CLOB column and it stores JSON string. lets say the column name is message. Now I am generating another JSON containing this message field along with some extra fields. It looks like below

{
  "groupId": "12345",
  "payloads": [
    {
      "message": "JSON",
      "key_value": "200",
      "kafkaTopic": "XXXX",
      "encryptInd": "Y"
    },
    {
      "message": "JSON",
      "key_value": "100",
      "kafkaTopic": "XXXX",
      "encryptInd": "Y"
    }
  ]
}

I am using JSON_OBJECT and JSON_ARRAYAGG to generate the final JSON. the query looks like

SELECT     JSON_OBJECT(KEY 'groupId' VALUE 12345,
                       KEY 'payloads' VALUE JSON_ARRAYAGG(JSON_OBJECT(KEY 'message'   VALUE gko.message,
                       KEY 'key_value' VALUE gko.key_value,
                       KEY 'kafkaTopic'  VALUE gkor.topic_name,
                       KEY 'encryptInd' VALUE gkor.encrypt_ind RETURNING CLOB)
                       RETURNING CLOB) RETURNING CLOB )

but the problem is JSON message with the tag 'message' is coming with escape "\" characters. like below

{"groupId":12345,"payloads":[{"message":"{\"code\":\"SALE\",\"header\":{\"tranType\":\"

Please let me know how to avoid the escape characters in message.

1 Answer 1

2

After changing the query in the below way escape characters no longer comes

JSON_OBJECT(KEY 'message'   VALUE gko.message FORMAT JSON
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.