Uploaded image for project: 'Calcite'
  1. Calcite
  2. CALCITE-4989

Nested JSON_OBJECT creation does not produce proper json

    XMLWordPrintableJSON

Details

    Description

      I am trying to create a nested json object using JSON_OBJECT and am getting a json with escaped quotes.  
       
      I have the following query in sql line :
       

      select JSON_OBJECT(
          KEY 'level1' 
          VALUE(
              JSON_OBJECT(
                  KEY 'level2' 
                  VALUE(
                       JSON_OBJECT(
                            KEY 'level3' 
                            VALUE 'val3')
                       )
                   )
               ) 
            ) 
      from (values ('{"a":{"b":2}}')) t(v);
       
      

      And it produces the result:
       

      -------------------------------------------------------------
      
                                 EXPR$0                            
      -------------------------------------------------------------
      
      {"level1":" {\"level2\":\"{\\\"level3\\\":\\\"val3\\\"}\"}"}
      -------------------------------------------------------------
      

       

      I was expecting the result as follows (without quote escapes):

       

      {"level1":{"level2":{"level3":"val3"}}}
       
      

      Also, see examples created by Stamatis

      https://github.com/zabetak/calcite/commit/988c13ce1ff551d6e4046a3c027ff298f79971f8

      Attachments

        Activity

          People

            libenchao Benchao Li
            mans2singh Mans Singh
            Votes:
            0 Vote for this issue
            Watchers:
            6 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Time Tracking

                Estimated:
                Original Estimate - Not Specified
                Not Specified
                Remaining:
                Remaining Estimate - 0h
                0h
                Logged:
                Time Spent - 1h
                1h